Skip to content

Commit

Permalink
launchatlogin fix, b/w icon, osx battery scale
Browse files Browse the repository at this point in the history
  • Loading branch information
David Wernhart committed Jun 4, 2020
1 parent 5185014 commit ffdf09b
Show file tree
Hide file tree
Showing 24 changed files with 131 additions and 38 deletions.
Binary file modified .DS_Store
Binary file not shown.
16 changes: 11 additions & 5 deletions AlDente.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@
92981ED423F08D9B00C05424 /* Frameworks */,
92981ED523F08D9B00C05424 /* Resources */,
9224A08623F1F6E300961AC4 /* CopyFiles */,
9240BF2F23FD3547005A710B /* Embed Frameworks */,
9286FB4B23F84C2B00BEB15B /* Embed Frameworks */,
92E24B4423F847B500BE41ED /* ShellScript */,
9240BF2F23FD3547005A710B /* Embed Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -367,6 +367,7 @@
PRODUCT_MODULE_NAME = AlDenteHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Frameworks";
};
Expand Down Expand Up @@ -397,6 +398,7 @@
PRODUCT_MODULE_NAME = AlDenteHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.0;
SYSTEM_FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/Frameworks";
};
Expand Down Expand Up @@ -457,6 +459,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SKIP_INSTALL = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
Expand Down Expand Up @@ -510,6 +513,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SKIP_INSTALL = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
Expand All @@ -523,7 +527,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"AlDente/Preview Content\"";
DEVELOPMENT_TEAM = 56C2L92EKW;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -538,10 +542,11 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.davidwernhart.AlDente;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = NO;
SWIFT_VERSION = 5.0;
};
name = Debug;
Expand All @@ -554,7 +559,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 4;
DEVELOPMENT_ASSET_PATHS = "\"AlDente/Preview Content\"";
DEVELOPMENT_TEAM = 56C2L92EKW;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -569,10 +574,11 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.1;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.davidwernhart.AlDente;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SKIP_INSTALL = NO;
SWIFT_VERSION = 5.0;
};
name = Release;
Expand Down
Binary file not shown.
Binary file modified AlDente/.DS_Store
Binary file not shown.
7 changes: 5 additions & 2 deletions AlDente/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Cocoa
import SwiftUI
import ServiceManagement
import Foundation
import LaunchAtLogin

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
Expand All @@ -33,14 +34,16 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let statusBar = NSStatusBar.system
statusBarItem = statusBar.statusItem(
withLength: NSStatusItem.squareLength)
statusBarItem.button?.title = "🍝"
statusBarItem.button?.image = NSImage(named: "menubaricon")!
//statusBarItem.button?.title = "🍝"

if let button = self.statusBarItem.button {
button.action = #selector(togglePopover(_:))
}

Helper.instance.checkHelperVersion()


LaunchAtLogin.isEnabled = true
}

@objc func togglePopover(_ sender: AnyObject?) {
Expand Down
54 changes: 54 additions & 0 deletions AlDente/Assets.xcassets/menubaricon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"images" : [
{
"filename" : "aldentelighticon1x.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "aldentedarkicon1x.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "aldentelighticon2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "aldentedarkicon2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 42 additions & 8 deletions AlDente/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ struct RedButtonStyle: ButtonStyle {
}
}

var osxScale:Bool = true

struct settings<Content: View>: View {


var content: () -> Content
@State var launchOnLogin = LaunchAtLogin.isEnabled
@State var osxScaleToggle = osxScale
@ObservedObject var presenter = SMCPresenter.shared


init(@ViewBuilder _ content: @escaping () -> Content) {
self.content = content
Expand Down Expand Up @@ -66,6 +71,19 @@ struct settings<Content: View>: View {
Text("Launch on Login")
}.padding()

Toggle(isOn: Binding(
get: {
self.osxScaleToggle
},
set: {(newValue) in
self.osxScaleToggle = newValue
osxScale = newValue
self.presenter.setValue(value: Float(self.presenter.value))
}
)) {
Text("Use MacOS battery scale")
}.padding()

Spacer()
Button( action: {
Helper.instance.installHelper()
Expand All @@ -80,7 +98,7 @@ struct settings<Content: View>: View {
HStack(alignment: .center) {
Spacer()
VStack(alignment: .leading){
Text("AlDente 🍝").font(.subheadline)
Text("AlDente 1.2 🍝").font(.subheadline)
Button(action:{
let url = URL(string: "https://www.github.com/davidwernhart/AlDente")!
if NSWorkspace.shared.open(url) {
Expand Down Expand Up @@ -114,7 +132,7 @@ struct ContentView: View{
@State var adaptableHeight = CGFloat(100)
@State var showSettings = false

@ObservedObject var presenter = SMCPresenter()
@ObservedObject var presenter = SMCPresenter.shared

init() {
Helper.instance.delegate = presenter
Expand Down Expand Up @@ -182,7 +200,8 @@ struct ContentView: View{

Spacer()
if(self.showSettings){
settings{Text("")}
//settings{Text("")}
settings({Text("")})
}

}.frame(width: 400, height: adaptableHeight)
Expand All @@ -195,12 +214,19 @@ struct ContentView: View{

class SMCPresenter: ObservableObject, HelperDelegate{

static let shared = SMCPresenter()

@Published var value: UInt8 = 0
private var timer: Timer?

func OnMaxBatRead(value: UInt8){
DispatchQueue.main.async {
self.value = value
if(osxScale){
self.value = value + 3
}
else{
self.value = value
}
}
}

Expand All @@ -209,11 +235,19 @@ class SMCPresenter: ObservableObject, HelperDelegate{
self.value = UInt8(value)
}
self.timer?.invalidate()

self.timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: false, block: { timer in
print("Setting Max Battery To: ",value)
Helper.instance.writeMaxBatteryCharge(setVal: UInt8(value))
Helper.instance.readMaxBatteryCharge()
self.timer = nil
var setval = value
if(osxScale){
setval -= 3
}
if(setval >= 20 && setval <= 100){
print("Setting Max Battery To: ",setval)
Helper.instance.writeMaxBatteryCharge(setVal: UInt8(setval))
Helper.instance.readMaxBatteryCharge()
self.timer = nil
}

})
}

Expand Down
Binary file modified Carthage/.DS_Store
Binary file not shown.
Binary file modified Carthage/Build/.DS_Store
Binary file not shown.
15 changes: 3 additions & 12 deletions Carthage/Build/.LaunchAtLogin.version

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Carthage/Build/Mac/LaunchAtLogin.framework/Versions/A/LaunchAtLogin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

0 comments on commit ffdf09b

Please sign in to comment.