diff --git a/.DS_Store b/.DS_Store index 789a08e..9e82716 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/AlDente.xcodeproj/project.pbxproj b/AlDente.xcodeproj/project.pbxproj index 9b30ce6..247f03a 100644 --- a/AlDente.xcodeproj/project.pbxproj +++ b/AlDente.xcodeproj/project.pbxproj @@ -8,11 +8,12 @@ /* Begin PBXBuildFile section */ 9224A08723F1F70600961AC4 /* com.davidwernhart.Helper in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9283741823F1F34400B8AE7A /* com.davidwernhart.Helper */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 9240BF2C23FD34E2005A710B /* LaunchAtLogin.framework.dSYM in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9240BF2B23FD34E2005A710B /* LaunchAtLogin.framework.dSYM */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; + 9240BF2D23FD3547005A710B /* LaunchAtLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9286FB4823F84C2B00BEB15B /* LaunchAtLogin.framework */; }; + 9240BF2E23FD3547005A710B /* LaunchAtLogin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9286FB4823F84C2B00BEB15B /* LaunchAtLogin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 927DBFC923F5478E00F8BF0D /* HelperToolProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927DBFC823F5478E00F8BF0D /* HelperToolProtocol.swift */; }; 927DBFCA23F5478E00F8BF0D /* HelperToolProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 927DBFC823F5478E00F8BF0D /* HelperToolProtocol.swift */; }; 9283741B23F1F34400B8AE7A /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9283741A23F1F34400B8AE7A /* main.swift */; }; - 9286FB4923F84C2B00BEB15B /* LaunchAtLogin.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9286FB4823F84C2B00BEB15B /* LaunchAtLogin.framework */; }; - 9286FB4A23F84C2B00BEB15B /* LaunchAtLogin.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9286FB4823F84C2B00BEB15B /* LaunchAtLogin.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 92981EDB23F08D9B00C05424 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92981EDA23F08D9B00C05424 /* AppDelegate.swift */; }; 92981EDD23F08D9B00C05424 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92981EDC23F08D9B00C05424 /* ContentView.swift */; }; 92981EDF23F08D9C00C05424 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 92981EDE23F08D9C00C05424 /* Assets.xcassets */; }; @@ -34,6 +35,17 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 9240BF2F23FD3547005A710B /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 9240BF2E23FD3547005A710B /* LaunchAtLogin.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; 9258163B23F5CBD500AB7387 /* Embed Frameworks */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; @@ -57,9 +69,9 @@ isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; - dstSubfolderSpec = 10; + dstSubfolderSpec = 16; files = ( - 9286FB4A23F84C2B00BEB15B /* LaunchAtLogin.framework in Embed Frameworks */, + 9240BF2C23FD34E2005A710B /* LaunchAtLogin.framework.dSYM in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -67,6 +79,8 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 9240BF2923FD3257005A710B /* LaunchAtLogin.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = LaunchAtLogin.framework.dSYM; path = Carthage/Build/Mac/LaunchAtLogin.framework.dSYM; sourceTree = ""; }; + 9240BF2B23FD34E2005A710B /* LaunchAtLogin.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = LaunchAtLogin.framework.dSYM; path = Carthage/Build/Mac/LaunchAtLogin.framework.dSYM; sourceTree = ""; }; 927DBFC623F533FB00F8BF0D /* Helper-Launchd.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Helper-Launchd.plist"; sourceTree = ""; }; 927DBFC823F5478E00F8BF0D /* HelperToolProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelperToolProtocol.swift; sourceTree = ""; }; 927DBFCB23F54C2C00F8BF0D /* HelperTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HelperTool.swift; sourceTree = ""; }; @@ -98,7 +112,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9286FB4923F84C2B00BEB15B /* LaunchAtLogin.framework in Frameworks */, + 9240BF2D23FD3547005A710B /* LaunchAtLogin.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -136,6 +150,8 @@ 92981ECE23F08D9B00C05424 = { isa = PBXGroup; children = ( + 9240BF2923FD3257005A710B /* LaunchAtLogin.framework.dSYM */, + 9240BF2B23FD34E2005A710B /* LaunchAtLogin.framework.dSYM */, 927DBFC723F545AF00F8BF0D /* Common */, 92981ED923F08D9B00C05424 /* AlDente */, 9283741923F1F34400B8AE7A /* com.davidwernhart.Helper */, @@ -205,8 +221,9 @@ 92981ED423F08D9B00C05424 /* Frameworks */, 92981ED523F08D9B00C05424 /* Resources */, 9224A08623F1F6E300961AC4 /* CopyFiles */, - 92E24B4423F847B500BE41ED /* ShellScript */, 9286FB4B23F84C2B00BEB15B /* Embed Frameworks */, + 92E24B4423F847B500BE41ED /* ShellScript */, + 9240BF2F23FD3547005A710B /* Embed Frameworks */, ); buildRules = ( ); @@ -283,7 +300,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "${PROJECT_DIR}/Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh\n"; + shellScript = "exec \"${PROJECT_DIR}/Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh\"\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -504,9 +521,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AlDente/AlDente.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"AlDente/Preview Content\""; DEVELOPMENT_TEAM = 56C2L92EKW; ENABLE_HARDENED_RUNTIME = YES; @@ -521,7 +538,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = com.davidwernhart.AlDente; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -535,9 +552,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AlDente/AlDente.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_ASSET_PATHS = "\"AlDente/Preview Content\""; DEVELOPMENT_TEAM = 56C2L92EKW; ENABLE_HARDENED_RUNTIME = YES; @@ -552,7 +569,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 1.1; PRODUCT_BUNDLE_IDENTIFIER = com.davidwernhart.AlDente; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/AlDente.xcodeproj/project.xcworkspace/xcuserdata/davidwernhart.xcuserdatad/UserInterfaceState.xcuserstate b/AlDente.xcodeproj/project.xcworkspace/xcuserdata/davidwernhart.xcuserdatad/UserInterfaceState.xcuserstate index c697e47..2ca9437 100644 Binary files a/AlDente.xcodeproj/project.xcworkspace/xcuserdata/davidwernhart.xcuserdatad/UserInterfaceState.xcuserstate and b/AlDente.xcodeproj/project.xcworkspace/xcuserdata/davidwernhart.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/AlDente/ContentView.swift b/AlDente/ContentView.swift index 48d6c6a..74e5d54 100644 --- a/AlDente/ContentView.swift +++ b/AlDente/ContentView.swift @@ -81,7 +81,15 @@ struct settings: View { Spacer() VStack(alignment: .leading){ Text("AlDente 🍝").font(.subheadline) - Text("github.com/davidwernhart/AlDente").foregroundColor(Color.blue) + Button(action:{ + let url = URL(string: "https://www.github.com/davidwernhart/AlDente")! + if NSWorkspace.shared.open(url) { + print("default browser was successfully opened") + } + }){ + Text("github.com/davidwernhart/AlDente").foregroundColor(Color.blue) + }.buttonStyle(PlainButtonStyle()) + Text("Created with 🤍 by David Wernhart in 2020") // Text("AlDente 🍝").font(.title) // Text("Keep your battery just right").font(.subheadline) diff --git a/AlDente/Info.plist b/AlDente/Info.plist index 60ece97..ab3d2eb 100644 --- a/AlDente/Info.plist +++ b/AlDente/Info.plist @@ -20,10 +20,12 @@ $(MARKETING_VERSION) CFBundleVersion $(CURRENT_PROJECT_VERSION) + LSApplicationCategoryType + public.app-category.developer-tools LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement - + NSHumanReadableCopyright Copyright © 2020 David Wernhart. All rights reserved. NSMainStoryboardFile @@ -37,7 +39,7 @@ SMPrivilegedExecutables com.davidwernhart.Helper - identifier "com.davidwernhart.Helper" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: david.wernhart96@gmail.com (GSDX9BQ584)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ + identifier "com.davidwernhart.Helper" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: david.wernhart96@gmail.com (GSDX9BQ584)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */ diff --git a/Carthage/.DS_Store b/Carthage/.DS_Store index eb65868..0b108a2 100644 Binary files a/Carthage/.DS_Store and b/Carthage/.DS_Store differ diff --git a/Carthage/Build/.DS_Store b/Carthage/Build/.DS_Store index d1c74c1..dc6a031 100644 Binary files a/Carthage/Build/.DS_Store and b/Carthage/Build/.DS_Store differ diff --git a/Carthage/Build/.LaunchAtLogin.version b/Carthage/Build/.LaunchAtLogin.version index cda06c5..9e5c6dd 100644 --- a/Carthage/Build/.LaunchAtLogin.version +++ b/Carthage/Build/.LaunchAtLogin.version @@ -2,7 +2,7 @@ "Mac" : [ { "name" : "LaunchAtLogin", - "hash" : "3aa89276b3b2caf4499607f2f8edc08acaa6b1ea55a5e9b42f7ca47c595f41d1", + "hash" : "2e9388c5a92a57f855ee3fd4af35f7bd9ca52e5b9b45da92d64104cf31cb017d", "swiftToolchainVersion" : "5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)" } ], diff --git a/Carthage/Build/Mac/LaunchAtLogin.framework.dSYM/Contents/Resources/DWARF/LaunchAtLogin b/Carthage/Build/Mac/LaunchAtLogin.framework.dSYM/Contents/Resources/DWARF/LaunchAtLogin index d1dcf26..014d67d 100644 Binary files a/Carthage/Build/Mac/LaunchAtLogin.framework.dSYM/Contents/Resources/DWARF/LaunchAtLogin and b/Carthage/Build/Mac/LaunchAtLogin.framework.dSYM/Contents/Resources/DWARF/LaunchAtLogin differ diff --git a/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/LaunchAtLogin b/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/LaunchAtLogin index 4ffa9e2..7a0ffdb 100755 Binary files a/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/LaunchAtLogin and b/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/LaunchAtLogin differ diff --git a/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/Resources/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper b/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/Resources/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper index 4d19f46..bf4dd52 100755 Binary files a/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/Resources/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper and b/Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/Resources/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper differ diff --git a/README.md b/README.md index fb09fe9..45a6784 100644 --- a/README.md +++ b/README.md @@ -1 +1,45 @@ -# AlDente +# AlDente 🍝 +_MacOS menu bar tool to limit maximum charging percentage_ + +##### Don't overcook your battery! Keep it fresh and chewy with AlDente. + +## Why do I need this? +Li-ion and polymer batteries (like the one in your MacBook) last the longest when operating between 30 and 80 percent. Keeping your battery at 100% at all times can shorten the lifespan of your notebook significantly. + +## How does it work? +The tool writes the desired value to your MacBooks SMC (System Management Controller), which handles the rest. +For everyone that is curious, the modified SMC key is called "BCLM" (Presumably "Battery Charge Level Max") + +## AlDente is tested and working on: +* 2019 MacBook Pro 16" +* 2017 Macbook Pro 13" without TouchBar +* 2017 MacBook Air 13" + + +## Download: + + +## How to use: +Simply open AlDente_Installer.dmg and drag the App to your Applications Folder. +On the first start, the application is going to ask you to allow installing a helper tool. This is necessary, since writing SMC Keys requires root privileges. +Once finished, enter your desired max. charging percentage by clicking on the 🍝 icon on your +menu bar. + +For some reason, MacOS will always try to squeeze in a few more percent than specified by the SMC. For example, if you set yours to 80% it will stop charging at around 83%, so be patient. Strangely, this is not the case using Windows with bootcamp, therefore I have chosen not to correct this inaccuracy in code for now. + +Usually, the operating system will take a minute or two registering the changes, so be patient. You can check if it's working by setting the max. percentage to e.g.: 70%. After a while, clicking on your battery icon will report "Battery is not charging" if you have more than ≈73% left, even tough your charger is connected. Notice that in this state, your MacBook is still powered by the charger, but the battery is not charging anymore. + +Other tools I used in this project: +* +* +* + +## Disclaimer: +I do not take any responsibility for any sort of damage in result of using this tool! Alltough this had no negative side effects for me, AlDente still taps in some very low level system functions that are not ment to be tampered with. Use it at your own risk! + +Copyright(c) 2020 David Wernhart +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.