Skip to content

Commit

Permalink
Big refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ribalba committed Sep 19, 2023
1 parent de6c705 commit 7cbf654
Show file tree
Hide file tree
Showing 19 changed files with 1,535 additions and 415 deletions.
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# hog

<img src="logo.png" width="100"/>

The hog is a tool that periodically collects energy statistics of your mac and makes them available to you.

There are two main aims:
Expand All @@ -17,9 +20,14 @@ give some statistics. You can either call it by hand and send it to the backgrou
For development purposes we recommend to always first run the program in the foreground and see if everything works fine
and then use the launch agent.

**IMPORTANT**:
### Launch agent

### Launch agent (still needs work)
This is a description on how to set everything up if you did a git clone. You can also just do

```
curl -fsSL https://raw.githubusercontent.com/green-coding-berlin/hog/main/install.sh | sudo bash
```
which will do the whole install for you.

Make the `power_logger.py` script executable with `chmod a+x power_logger.py`

Expand Down Expand Up @@ -58,9 +66,18 @@ If you want to unload or stop the service:
sudo launchctl unload /Library/LaunchDaemons/berlin.green-coding.hog.plist
```

### Settings

It is possible to configure your own settings by using a `settings.ini` file in the same directory as the `power_logger.py`
script. Following keys are currently used:

- `powermetrics`: This is the delta in ms that power metrics should take samples. So if you set this to 5000 powermetrics will return the aggregated values every 5 seconds
- `upload_delta`: This is the time delta data should be uploaded in seconds.
- `api_url`: The url endpoint the data should be uploaded to. You can use the https://github.com/green-coding-berlin/green-metrics-tool if you want but also write/ use your own backend.

## The desktop App

The hog desktop app gives you analytics of the data that was recorded.
The hog desktop app gives you analytics of the data that was recorded. Please move this into your app folder.

## Database

Expand All @@ -69,3 +86,18 @@ All data is saved in an sqlite database that is located under:
```bash
/Library/Application Support/berlin.green-coding.hog/db.db
```

## Contributing

PRs are always welcome. Feel free to drop us an email or look into the issues.

The hog is developed to not need any dependencies.

## Screenshots

<img src="Screenshot.png" width="300"/>

## Sources

- Logo from https://pixabay.com/de/vectors/schwein-schweinchen-ferkel-2660356/
- Caribou (Public Domain) lib from https://raw.githubusercontent.com/clutchski/caribou/master/caribou.py
Binary file added Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 8 additions & 8 deletions app/hog/hog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/* Begin PBXBuildFile section */
0A69EDE42AA0820E00F4A364 /* DetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A69EDE32AA0820E00F4A364 /* DetailView.swift */; };
0A6C64572AAF5F9A00664D98 /* demo_db.db in Resources */ = {isa = PBXBuildFile; fileRef = 0A6C64562AAF5F9A00664D98 /* demo_db.db */; };
0AEC07772A40D4C2003C82E7 /* hogApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEC07762A40D4C2003C82E7 /* hogApp.swift */; };
0AEC07792A40D4C2003C82E7 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEC07782A40D4C2003C82E7 /* ContentView.swift */; };
0AEC077B2A40D4C3003C82E7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AEC077A2A40D4C3003C82E7 /* Assets.xcassets */; };
0AEC077E2A40D4C3003C82E7 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0AEC077D2A40D4C3003C82E7 /* Preview Assets.xcassets */; };
0AEC07892A40D4C3003C82E7 /* hogTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AEC07882A40D4C3003C82E7 /* hogTests.swift */; };
Expand All @@ -36,10 +36,10 @@

/* Begin PBXFileReference section */
0A69EDE32AA0820E00F4A364 /* DetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = "<group>"; };
0AAD6F392AA734A100416201 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
0A6C64552AACBA5A00664D98 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
0A6C64562AAF5F9A00664D98 /* demo_db.db */ = {isa = PBXFileReference; lastKnownFileType = text; path = demo_db.db; sourceTree = "<group>"; };
0AEC07732A40D4C2003C82E7 /* hog.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = hog.app; sourceTree = BUILT_PRODUCTS_DIR; };
0AEC07762A40D4C2003C82E7 /* hogApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = hogApp.swift; sourceTree = "<group>"; };
0AEC07782A40D4C2003C82E7 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
0AEC077A2A40D4C3003C82E7 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
0AEC077D2A40D4C3003C82E7 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
0AEC077F2A40D4C3003C82E7 /* hog.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = hog.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -98,13 +98,13 @@
0AEC07752A40D4C2003C82E7 /* hog */ = {
isa = PBXGroup;
children = (
0AAD6F392AA734A100416201 /* Info.plist */,
0A6C64552AACBA5A00664D98 /* Info.plist */,
0AEC07762A40D4C2003C82E7 /* hogApp.swift */,
0AEC07782A40D4C2003C82E7 /* ContentView.swift */,
0A69EDE32AA0820E00F4A364 /* DetailView.swift */,
0AEC077A2A40D4C3003C82E7 /* Assets.xcassets */,
0AEC077F2A40D4C3003C82E7 /* hog.entitlements */,
0AEC077C2A40D4C3003C82E7 /* Preview Content */,
0A6C64562AAF5F9A00664D98 /* demo_db.db */,
);
path = hog;
sourceTree = "<group>";
Expand Down Expand Up @@ -238,6 +238,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0A6C64572AAF5F9A00664D98 /* demo_db.db in Resources */,
0AEC077E2A40D4C3003C82E7 /* Preview Assets.xcassets in Resources */,
0AEC077B2A40D4C3003C82E7 /* Assets.xcassets in Resources */,
);
Expand All @@ -264,7 +265,6 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0AEC07792A40D4C2003C82E7 /* ContentView.swift in Sources */,
0A69EDE42AA0820E00F4A364 /* DetailView.swift in Sources */,
0AEC07772A40D4C2003C82E7 /* hogApp.swift in Sources */,
);
Expand Down Expand Up @@ -428,7 +428,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1xv;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"hog/Preview Content\"";
DEVELOPMENT_TEAM = SBWA476E6F;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down Expand Up @@ -461,7 +461,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1xv;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"hog/Preview Content\"";
DEVELOPMENT_TEAM = SBWA476E6F;
ENABLE_HARDENED_RUNTIME = YES;
Expand Down
Binary file not shown.
20 changes: 20 additions & 0 deletions app/hog/hog/Assets.xcassets/Image.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions app/hog/hog/Assets.xcassets/logo2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "128-mac.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 7cbf654

Please sign in to comment.