diff --git a/README.md b/README.md index 7dd2688..0f91320 100644 --- a/README.md +++ b/README.md @@ -135,4 +135,10 @@ The hog is developed to not need any dependencies. ## 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 \ No newline at end of file +- Caribou (Public Domain) lib from https://raw.githubusercontent.com/clutchski/caribou/master/caribou.py + +## Misc + +- If you can't see the hog logo in the menu bar because of the notch there are multiple solutions. + - you can use a tool like https://www.macbartender.com/Bartender4/ + - you can use the the command `$ sudo /usr/local/bin/hog/power_logger.py -w` to display the url. \ No newline at end of file diff --git a/app/hog/hog.xcodeproj/project.pbxproj b/app/hog/hog.xcodeproj/project.pbxproj index 84526f4..d93d6f6 100644 --- a/app/hog/hog.xcodeproj/project.pbxproj +++ b/app/hog/hog.xcodeproj/project.pbxproj @@ -7,6 +7,13 @@ objects = { /* Begin PBXBuildFile section */ + 0A21F0132AC6D0DA0036252A /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A21F0122AC6D0DA0036252A /* WidgetKit.framework */; }; + 0A21F0152AC6D0DA0036252A /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0A21F0142AC6D0DA0036252A /* SwiftUI.framework */; }; + 0A21F0182AC6D0DA0036252A /* widgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21F0172AC6D0DA0036252A /* widgetBundle.swift */; }; + 0A21F01A2AC6D0DA0036252A /* widget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21F0192AC6D0DA0036252A /* widget.swift */; }; + 0A21F01C2AC6D0DA0036252A /* AppIntent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A21F01B2AC6D0DA0036252A /* AppIntent.swift */; }; + 0A21F01E2AC6D0DB0036252A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0A21F01D2AC6D0DB0036252A /* Assets.xcassets */; }; + 0A21F0232AC6D0DB0036252A /* widgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 0A21F0102AC6D0DA0036252A /* widgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 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 */; }; @@ -18,6 +25,13 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ + 0A21F0212AC6D0DB0036252A /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 0AEC076B2A40D4C2003C82E7 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 0A21F00F2AC6D0DA0036252A; + remoteInfo = widgetExtension; + }; 0AEC07852A40D4C3003C82E7 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0AEC076B2A40D4C2003C82E7 /* Project object */; @@ -34,7 +48,30 @@ }; /* End PBXContainerItemProxy section */ +/* Begin PBXCopyFilesBuildPhase section */ + 0A21F0242AC6D0DB0036252A /* Embed Foundation Extensions */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 13; + files = ( + 0A21F0232AC6D0DB0036252A /* widgetExtension.appex in Embed Foundation Extensions */, + ); + name = "Embed Foundation Extensions"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ + 0A21F0102AC6D0DA0036252A /* widgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = widgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + 0A21F0122AC6D0DA0036252A /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; + 0A21F0142AC6D0DA0036252A /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; + 0A21F0172AC6D0DA0036252A /* widgetBundle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = widgetBundle.swift; sourceTree = ""; }; + 0A21F0192AC6D0DA0036252A /* widget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = widget.swift; sourceTree = ""; }; + 0A21F01B2AC6D0DA0036252A /* AppIntent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppIntent.swift; sourceTree = ""; }; + 0A21F01D2AC6D0DB0036252A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0A21F01F2AC6D0DB0036252A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 0A21F0202AC6D0DB0036252A /* widget.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = widget.entitlements; sourceTree = ""; }; 0A69EDE32AA0820E00F4A364 /* DetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailView.swift; sourceTree = ""; }; 0A6C64552AACBA5A00664D98 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; 0A6C64562AAF5F9A00664D98 /* demo_db.db */ = {isa = PBXFileReference; lastKnownFileType = text; path = demo_db.db; sourceTree = ""; }; @@ -51,6 +88,15 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + 0A21F00D2AC6D0DA0036252A /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0A21F0152AC6D0DA0036252A /* SwiftUI.framework in Frameworks */, + 0A21F0132AC6D0DA0036252A /* WidgetKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 0AEC07702A40D4C2003C82E7 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -75,12 +121,36 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 0A21F0112AC6D0DA0036252A /* Frameworks */ = { + isa = PBXGroup; + children = ( + 0A21F0122AC6D0DA0036252A /* WidgetKit.framework */, + 0A21F0142AC6D0DA0036252A /* SwiftUI.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 0A21F0162AC6D0DA0036252A /* widget */ = { + isa = PBXGroup; + children = ( + 0A21F0172AC6D0DA0036252A /* widgetBundle.swift */, + 0A21F0192AC6D0DA0036252A /* widget.swift */, + 0A21F01B2AC6D0DA0036252A /* AppIntent.swift */, + 0A21F01D2AC6D0DB0036252A /* Assets.xcassets */, + 0A21F01F2AC6D0DB0036252A /* Info.plist */, + 0A21F0202AC6D0DB0036252A /* widget.entitlements */, + ); + path = widget; + sourceTree = ""; + }; 0AEC076A2A40D4C2003C82E7 = { isa = PBXGroup; children = ( 0AEC07752A40D4C2003C82E7 /* hog */, 0AEC07872A40D4C3003C82E7 /* hogTests */, 0AEC07912A40D4C3003C82E7 /* hogUITests */, + 0A21F0162AC6D0DA0036252A /* widget */, + 0A21F0112AC6D0DA0036252A /* Frameworks */, 0AEC07742A40D4C2003C82E7 /* Products */, ); sourceTree = ""; @@ -91,6 +161,7 @@ 0AEC07732A40D4C2003C82E7 /* hog.app */, 0AEC07842A40D4C3003C82E7 /* hogTests.xctest */, 0AEC078E2A40D4C3003C82E7 /* hogUITests.xctest */, + 0A21F0102AC6D0DA0036252A /* widgetExtension.appex */, ); name = Products; sourceTree = ""; @@ -137,6 +208,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ + 0A21F00F2AC6D0DA0036252A /* widgetExtension */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0A21F0272AC6D0DB0036252A /* Build configuration list for PBXNativeTarget "widgetExtension" */; + buildPhases = ( + 0A21F00C2AC6D0DA0036252A /* Sources */, + 0A21F00D2AC6D0DA0036252A /* Frameworks */, + 0A21F00E2AC6D0DA0036252A /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = widgetExtension; + productName = widgetExtension; + productReference = 0A21F0102AC6D0DA0036252A /* widgetExtension.appex */; + productType = "com.apple.product-type.app-extension"; + }; 0AEC07722A40D4C2003C82E7 /* hog */ = { isa = PBXNativeTarget; buildConfigurationList = 0AEC07982A40D4C3003C82E7 /* Build configuration list for PBXNativeTarget "hog" */; @@ -144,10 +232,12 @@ 0AEC076F2A40D4C2003C82E7 /* Sources */, 0AEC07702A40D4C2003C82E7 /* Frameworks */, 0AEC07712A40D4C2003C82E7 /* Resources */, + 0A21F0242AC6D0DB0036252A /* Embed Foundation Extensions */, ); buildRules = ( ); dependencies = ( + 0A21F0222AC6D0DB0036252A /* PBXTargetDependency */, ); name = hog; productName = hog; @@ -197,9 +287,12 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1430; + LastSwiftUpdateCheck = 1500; LastUpgradeCheck = 1500; TargetAttributes = { + 0A21F00F2AC6D0DA0036252A = { + CreatedOnToolsVersion = 15.0; + }; 0AEC07722A40D4C2003C82E7 = { CreatedOnToolsVersion = 14.3.1; }; @@ -229,11 +322,20 @@ 0AEC07722A40D4C2003C82E7 /* hog */, 0AEC07832A40D4C3003C82E7 /* hogTests */, 0AEC078D2A40D4C3003C82E7 /* hogUITests */, + 0A21F00F2AC6D0DA0036252A /* widgetExtension */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + 0A21F00E2AC6D0DA0036252A /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0A21F01E2AC6D0DB0036252A /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 0AEC07712A40D4C2003C82E7 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -261,6 +363,16 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + 0A21F00C2AC6D0DA0036252A /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0A21F0182AC6D0DA0036252A /* widgetBundle.swift in Sources */, + 0A21F01A2AC6D0DA0036252A /* widget.swift in Sources */, + 0A21F01C2AC6D0DA0036252A /* AppIntent.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; 0AEC076F2A40D4C2003C82E7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -290,6 +402,11 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ + 0A21F0222AC6D0DB0036252A /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 0A21F00F2AC6D0DA0036252A /* widgetExtension */; + targetProxy = 0A21F0212AC6D0DB0036252A /* PBXContainerItemProxy */; + }; 0AEC07862A40D4C3003C82E7 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 0AEC07722A40D4C2003C82E7 /* hog */; @@ -303,6 +420,69 @@ /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ + 0A21F0252AC6D0DB0036252A /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_ENTITLEMENTS = widget/widget.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = SBWA476E6F; + ENABLE_HARDENED_RUNTIME = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = widget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = widget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "berlin.green-coding.hog.widget"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 0A21F0262AC6D0DB0036252A /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + ASSETCATALOG_COMPILER_WIDGET_BACKGROUND_COLOR_NAME = WidgetBackground; + CODE_SIGN_ENTITLEMENTS = widget/widget.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_TEAM = SBWA476E6F; + ENABLE_HARDENED_RUNTIME = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_FILE = widget/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = widget; + INFOPLIST_KEY_NSHumanReadableCopyright = ""; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + "@executable_path/../../../../Frameworks", + ); + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.0; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = "berlin.green-coding.hog.widget"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; 0AEC07962A40D4C3003C82E7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -427,6 +607,7 @@ 0AEC07992A40D4C3003C82E7 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; @@ -461,6 +642,7 @@ 0AEC079A2A40D4C3003C82E7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; @@ -571,6 +753,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + 0A21F0272AC6D0DB0036252A /* Build configuration list for PBXNativeTarget "widgetExtension" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0A21F0252AC6D0DB0036252A /* Debug */, + 0A21F0262AC6D0DB0036252A /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; 0AEC076E2A40D4C2003C82E7 /* Build configuration list for PBXProject "hog" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/app/hog/hog.xcodeproj/project.xcworkspace/xcuserdata/didi.xcuserdatad/UserInterfaceState.xcuserstate b/app/hog/hog.xcodeproj/project.xcworkspace/xcuserdata/didi.xcuserdatad/UserInterfaceState.xcuserstate index 00be01d..4446bd4 100644 Binary files a/app/hog/hog.xcodeproj/project.xcworkspace/xcuserdata/didi.xcuserdatad/UserInterfaceState.xcuserstate and b/app/hog/hog.xcodeproj/project.xcworkspace/xcuserdata/didi.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/app/hog/hog.xcodeproj/xcuserdata/didi.xcuserdatad/xcschemes/xcschememanagement.plist b/app/hog/hog.xcodeproj/xcuserdata/didi.xcuserdatad/xcschemes/xcschememanagement.plist index a9b6020..618e029 100644 --- a/app/hog/hog.xcodeproj/xcuserdata/didi.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/app/hog/hog.xcodeproj/xcuserdata/didi.xcuserdatad/xcschemes/xcschememanagement.plist @@ -9,6 +9,11 @@ orderHint 0 + widgetExtension.xcscheme_^#shared#^_ + + orderHint + 1 + SuppressBuildableAutocreation diff --git a/app/hog/hog/DetailView.swift b/app/hog/hog/DetailView.swift index 3049faf..7640c8c 100644 --- a/app/hog/hog/DetailView.swift +++ b/app/hog/hog/DetailView.swift @@ -661,7 +661,7 @@ struct DataView: View { } var body: some View { - VStack{ + VStack(){ HStack { VStack(alignment: .leading, spacing: 8) { @@ -721,7 +721,7 @@ struct DataView: View { } }) { Text("View Detailed Analytics") - .padding(20) + .padding(10) } @@ -900,6 +900,13 @@ struct StepsView: View { .scaledToFit() .frame(width: 50, height: 50) Text("Welcome to the hog").font(.title) + Spacer() + Button(action: { + exit(0) + }) { + Image(systemName: "x.circle") + } + } Text("It looks like you haven't installed the program that we need to collect the power measurments. Please follow these steps:") Divider() diff --git a/app/hog/widget/AppIntent.swift b/app/hog/widget/AppIntent.swift new file mode 100644 index 0000000..b6c1cb1 --- /dev/null +++ b/app/hog/widget/AppIntent.swift @@ -0,0 +1,18 @@ +// +// AppIntent.swift +// widget +// +// Created by Didi Hoffmann on 29.09.23. +// + +import WidgetKit +import AppIntents + +struct ConfigurationAppIntent: WidgetConfigurationIntent { + static var title: LocalizedStringResource = "Configuration" + static var description = IntentDescription("This is an example widget.") + + // An example configurable parameter. + @Parameter(title: "Favorite Emoji", default: "😃") + var favoriteEmoji: String +} diff --git a/app/hog/widget/Assets.xcassets/AccentColor.colorset/Contents.json b/app/hog/widget/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/app/hog/widget/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app/hog/widget/Assets.xcassets/AppIcon.appiconset/Contents.json b/app/hog/widget/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..3f00db4 --- /dev/null +++ b/app/hog/widget/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "mac", + "scale" : "1x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "16x16" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "32x32" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "128x128" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "256x256" + }, + { + "idiom" : "mac", + "scale" : "1x", + "size" : "512x512" + }, + { + "idiom" : "mac", + "scale" : "2x", + "size" : "512x512" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app/hog/widget/Assets.xcassets/Contents.json b/app/hog/widget/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/app/hog/widget/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app/hog/widget/Assets.xcassets/WidgetBackground.colorset/Contents.json b/app/hog/widget/Assets.xcassets/WidgetBackground.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/app/hog/widget/Assets.xcassets/WidgetBackground.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/app/hog/widget/Info.plist b/app/hog/widget/Info.plist new file mode 100644 index 0000000..0f118fb --- /dev/null +++ b/app/hog/widget/Info.plist @@ -0,0 +1,11 @@ + + + + + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/app/hog/widget/widget.entitlements b/app/hog/widget/widget.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/app/hog/widget/widget.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/app/hog/widget/widget.swift b/app/hog/widget/widget.swift new file mode 100644 index 0000000..4c9a719 --- /dev/null +++ b/app/hog/widget/widget.swift @@ -0,0 +1,63 @@ +// +// widget.swift +// widget +// +// Created by Didi Hoffmann on 29.09.23. +// + +import WidgetKit +import SwiftUI + +struct Provider: AppIntentTimelineProvider { + func placeholder(in context: Context) -> SimpleEntry { + SimpleEntry(date: Date(), configuration: ConfigurationAppIntent()) + } + + func snapshot(for configuration: ConfigurationAppIntent, in context: Context) async -> SimpleEntry { + SimpleEntry(date: Date(), configuration: configuration) + } + + func timeline(for configuration: ConfigurationAppIntent, in context: Context) async -> Timeline { + var entries: [SimpleEntry] = [] + + // Generate a timeline consisting of five entries an hour apart, starting from the current date. + let currentDate = Date() + for hourOffset in 0 ..< 5 { + let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)! + let entry = SimpleEntry(date: entryDate, configuration: configuration) + entries.append(entry) + } + + return Timeline(entries: entries, policy: .atEnd) + } +} + +struct SimpleEntry: TimelineEntry { + let date: Date + let configuration: ConfigurationAppIntent +} + +struct widgetEntryView : View { + var entry: Provider.Entry + + var body: some View { + VStack { + Text("Time:") + Text(entry.date, style: .time) + + Text("Favorite Emoji:") + Text(entry.configuration.favoriteEmoji) + } + } +} + +struct widget: Widget { + let kind: String = "widget" + + var body: some WidgetConfiguration { + AppIntentConfiguration(kind: kind, intent: ConfigurationAppIntent.self, provider: Provider()) { entry in + widgetEntryView(entry: entry) + .containerBackground(.fill.tertiary, for: .widget) + } + } +} diff --git a/app/hog/widget/widgetBundle.swift b/app/hog/widget/widgetBundle.swift new file mode 100644 index 0000000..79d5c4a --- /dev/null +++ b/app/hog/widget/widgetBundle.swift @@ -0,0 +1,16 @@ +// +// widgetBundle.swift +// widget +// +// Created by Didi Hoffmann on 29.09.23. +// + +import WidgetKit +import SwiftUI + +@main +struct widgetBundle: WidgetBundle { + var body: some Widget { + widget() + } +} diff --git a/hog.app/Contents/Info.plist b/hog.app/Contents/Info.plist index a13ab0f..a4dca2f 100644 --- a/hog.app/Contents/Info.plist +++ b/hog.app/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 22G91 + 23A344 CFBundleDevelopmentRegion en CFBundleDisplayName diff --git a/hog.app/Contents/MacOS/hog b/hog.app/Contents/MacOS/hog index 0a71938..7ca6ce6 100755 Binary files a/hog.app/Contents/MacOS/hog and b/hog.app/Contents/MacOS/hog differ diff --git a/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Info.plist b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Info.plist new file mode 100644 index 0000000..9db6fb5 --- /dev/null +++ b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Info.plist @@ -0,0 +1,53 @@ + + + + + BuildMachineOSBuild + 23A344 + CFBundleDevelopmentRegion + en + CFBundleDisplayName + widget + CFBundleExecutable + widgetExtension + CFBundleIdentifier + berlin.green-coding.hog.widget + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + widgetExtension + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + + DTPlatformName + macosx + DTPlatformVersion + 14.0 + DTSDKBuild + 23A334 + DTSDKName + macosx14.0 + DTXcode + 1500 + DTXcodeBuild + 15A240d + LSMinimumSystemVersion + 14.0 + NSExtension + + NSExtensionPointIdentifier + com.apple.widgetkit-extension + + + diff --git a/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/MacOS/widgetExtension b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/MacOS/widgetExtension new file mode 100755 index 0000000..808ec58 Binary files /dev/null and b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/MacOS/widgetExtension differ diff --git a/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/extract.actionsdata b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/extract.actionsdata new file mode 100644 index 0000000..1f3f899 --- /dev/null +++ b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/extract.actionsdata @@ -0,0 +1 @@ +{"entities":{},"shortcutTileColor":14,"generator":{"name":"xcode-tools","version":"15.0"},"negativePhrases":[],"queries":{},"enums":[],"autoShortcuts":[],"version":1,"actions":{"ConfigurationAppIntent":{"mangledTypeName":"15widgetExtension22ConfigurationAppIntentV","systemProtocols":["com.apple.link.systemProtocol.WidgetConfiguration"],"title":{"key":"Configuration"},"mangledTypeNameByBundleIdentifier":{},"presentationStyle":0,"parameters":[{"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}},"isInput":false,"dynamicOptionsSupport":0,"inputConnectionBehavior":0,"resolvableInputTypes":[{"valueType":{"primitive":{"wrapper":{"typeIdentifier":0}}},"kindValue":0},{"valueType":{"primitive":{"wrapper":{"typeIdentifier":2}}},"kindValue":0},{"kindValue":0,"valueType":{"array":{"wrapper":{"capabilities":3,"memberValueType":{"primitive":{"wrapper":{"typeIdentifier":2}}}}}}}],"isOptional":false,"title":{"key":"Favorite Emoji"},"name":"favoriteEmoji","typeSpecificMetadata":["LNValueTypeSpecificMetadataKeyDefaultValue",{"string":{"wrapper":"😃"}}]}],"outputFlags":8,"availabilityAnnotations":{"LNPlatformNameWildcard":{"introducedVersion":"*"}},"requiredCapabilities":[],"authenticationPolicy":0,"openAppWhenRun":false,"systemProtocolMetadata":["com.apple.link.systemProtocol.WidgetConfiguration",{"empty":{}}],"isDiscoverable":true,"identifier":"ConfigurationAppIntent","effectiveBundleIdentifiers":[],"descriptionMetadata":{"descriptionText":{"key":"This is an example widget."},"searchKeywords":[]},"typeSpecificMetadata":[]}}} \ No newline at end of file diff --git a/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/version.json b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/version.json new file mode 100644 index 0000000..ff1bbc5 --- /dev/null +++ b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/Resources/Metadata.appintents/version.json @@ -0,0 +1,4 @@ +{ + "toolsVersion" : "15.0", + "version" : "3.0" +} \ No newline at end of file diff --git a/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/_CodeSignature/CodeResources b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/_CodeSignature/CodeResources new file mode 100644 index 0000000..19bc11c --- /dev/null +++ b/hog.app/Contents/PlugIns/widgetExtension.appex/Contents/_CodeSignature/CodeResources @@ -0,0 +1,139 @@ + + + + + files + + Resources/Metadata.appintents/extract.actionsdata + + wqXj5Me4Mq7gT2GtWItAHpugKDs= + + Resources/Metadata.appintents/version.json + + 5gmL5nUt9kmH2N/JaR6rntCwxLY= + + + files2 + + Resources/Metadata.appintents/extract.actionsdata + + hash2 + + OUFgh/B4rNjHUO/jU58ff7aWhMUijgxUL52gZXpj+qE= + + + Resources/Metadata.appintents/version.json + + hash2 + + cG6iFb/rAMRIDAfpRQoWlGyJwUT9CrZkacy6zW5zUGU= + + + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/hog.app/Contents/Resources/Assets.car b/hog.app/Contents/Resources/Assets.car index 33f013a..04a5eff 100644 Binary files a/hog.app/Contents/Resources/Assets.car and b/hog.app/Contents/Resources/Assets.car differ diff --git a/hog.app/Contents/_CodeSignature/CodeResources b/hog.app/Contents/_CodeSignature/CodeResources index e8f3cd8..db5a879 100644 --- a/hog.app/Contents/_CodeSignature/CodeResources +++ b/hog.app/Contents/_CodeSignature/CodeResources @@ -10,7 +10,7 @@ Resources/Assets.car - ZzCJz9XoXNSp0RECXMKKF0A0qsY= + JEs/wJ+/rf/gdTqgVGb2dIewI48= Resources/demo_db.db @@ -19,6 +19,15 @@ files2 + PlugIns/widgetExtension.appex + + cdhash + + q14NRvIGozs0CRJpPS+8F/3Xhbs= + + requirement + identifier "berlin.green-coding.hog.widget" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: Dietger Hoffmann (899DULE8SZ)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ + Resources/AppIcon.icns hash2 @@ -30,7 +39,7 @@ hash2 - nSTOBfK1SHjTRnjJWSlyNElvk/MVGWyMvAORkrjjXsE= + bNknJFZh9mi83dgVX4S0/Oc6jH24x4RUXrzI0TNCbHI= Resources/demo_db.db diff --git a/install.sh b/install.sh index b8cf45b..0bb12e0 100644 --- a/install.sh +++ b/install.sh @@ -33,19 +33,26 @@ install_xcode_clt() { # Call the function to ensure Xcode Command Line Tools are installed install_xcode_clt +hog_running_output=$(launchctl list | grep berlin.green-coding.hog) + +if [[ ! -z "$hog_running_output" ]]; then + launchctl unload /Library/LaunchDaemons/berlin.green-coding.hog.plist + rm -f /tmp/latest_release.zip +fi + ZIP_LOCATION=$(curl -s https://api.github.com/repos/green-coding-berlin/hog/releases/latest | grep -o 'https://[^"]*/hog_power_logger.zip') curl -fLo /tmp/latest_release.zip $ZIP_LOCATION mkdir -p /usr/local/bin/hog -unzip /tmp/latest_release.zip -d /usr/local/bin/hog/ +unzip /tmp/latest_release.zip -o -u -d /usr/local/bin/hog/ rm /tmp/latest_release.zip chmod 755 /usr/local/bin/hog chmod -R 755 /usr/local/bin/hog/ chmod +x /usr/local/bin/hog/power_logger.py -mv /usr/local/bin/hog/berlin.green-coding.hog.plist /Library/LaunchDaemons/berlin.green-coding.hog.plist +mv -f /usr/local/bin/hog/berlin.green-coding.hog.plist /Library/LaunchDaemons/berlin.green-coding.hog.plist sed -i '' "s|PATH_PLEASE_CHANGE|/usr/local/bin/hog/|g" /Library/LaunchDaemons/berlin.green-coding.hog.plist diff --git a/make_release.sh b/make_release.sh index bb1a5b2..0276091 100644 --- a/make_release.sh +++ b/make_release.sh @@ -5,6 +5,7 @@ files_to_zip=( "berlin.green-coding.hog.plist" "power_logger.py" "libs/" + "settings.ini" ) exclude_patterns=() @@ -16,3 +17,4 @@ zip -r hog_power_logger.zip "${files_to_zip[@]}" "${exclude_patterns[@]}" echo "Files have been zipped into hog_power_logger.zip" echo "Now create a new release on github and then delete the zip" +grep 'VERSION' power_logger.py diff --git a/power_logger.py b/power_logger.py index 229bc07..d1fb2b1 100755 --- a/power_logger.py +++ b/power_logger.py @@ -24,6 +24,7 @@ from libs import caribou +VERSION = '0.2.1' # Shared variable to signal the thread to stop stop_signal = False @@ -67,7 +68,7 @@ def siginfo_handler(_, __): 'powermetrics': 5000, 'upload_delta': 300, 'api_url': 'https://api.green-coding.berlin/v1/hog/add', - 'web_url': 'http://metrics.green-coding.berlin/hog-details.html?machine_uuid=', + 'web_url': 'https://metrics.green-coding.berlin/hog-details.html?machine_uuid=', 'upload_data': True, } @@ -168,6 +169,7 @@ def upload_data_to_endpoint(): # We don't need this in the DB on the server del settings_upload['api_url'] del settings_upload['web_url'] + settings_upload['client_version'] = VERSION payload.append({ 'time': time_val, @@ -176,7 +178,6 @@ def upload_data_to_endpoint(): 'machine_uuid': machine_uuid, 'row_id': row_id }) - request_data = json.dumps(payload).encode('utf-8') req = urllib.request.Request(url=SETTINGS['api_url'], data=request_data, diff --git a/settings.ini b/settings.ini index e4796e9..1c63343 100644 --- a/settings.ini +++ b/settings.ini @@ -1,6 +1,6 @@ [DEFAULT] api_url = https://api.green-coding.berlin/v1/hog/add -web_url = http://metrics.green-coding.berlin/hog-details.html?machine_uuid= +web_url = https://metrics.green-coding.berlin/hog-details.html?machine_uuid= upload_delta = 300 powermetrics = 5000 -upload_data = true \ No newline at end of file +upload_data = true