-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David Wernhart
committed
Feb 14, 2021
0 parents
commit 77119a1
Showing
30 changed files
with
3,178 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
AlDente.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
AlDente.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
16 changes: 16 additions & 0 deletions
16
AlDente.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"object": { | ||
"pins": [ | ||
{ | ||
"package": "LaunchAtLogin", | ||
"repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin", | ||
"state": { | ||
"branch": null, | ||
"revision": "0f39982b9d6993eef253b81219d3c39ba1e680f3", | ||
"version": "4.0.0" | ||
} | ||
} | ||
] | ||
}, | ||
"version": 1 | ||
} |
Binary file added
BIN
+71.3 KB
...j/project.xcworkspace/xcuserdata/davidwernhart.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
24 changes: 24 additions & 0 deletions
24
AlDente.xcodeproj/xcuserdata/davidwernhart.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
uuid = "0B65810B-47FA-44B5-B39C-4D764B29033A" | ||
type = "1" | ||
version = "2.0"> | ||
<Breakpoints> | ||
<BreakpointProxy | ||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
<BreakpointContent | ||
uuid = "15EAC10E-2093-4C1F-817D-D17853B691FE" | ||
shouldBeEnabled = "No" | ||
ignoreCount = "0" | ||
continueAfterRunningActions = "No" | ||
filePath = "AlDente/ContentView.swift" | ||
startingColumnNumber = "9223372036854775807" | ||
endingColumnNumber = "9223372036854775807" | ||
startingLineNumber = "37" | ||
endingLineNumber = "37" | ||
landmarkName = "Settings" | ||
landmarkType = "14"> | ||
</BreakpointContent> | ||
</BreakpointProxy> | ||
</Breakpoints> | ||
</Bucket> |
39 changes: 39 additions & 0 deletions
39
AlDente.xcodeproj/xcuserdata/davidwernhart.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>AlDente Pro.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>2</integer> | ||
</dict> | ||
<key>AlDente copy.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>2</integer> | ||
</dict> | ||
<key>AlDente.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>1</integer> | ||
</dict> | ||
<key>Hall.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
<key>Helper.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>2</integer> | ||
</dict> | ||
<key>com.davidwernhart.Helper.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// | ||
// AppDelegate.swift | ||
// AlDente | ||
// | ||
// Created by David Wernhart on 09.02.20. | ||
// Copyright © 2020 David Wernhart. All rights reserved. | ||
// | ||
|
||
import AppKit | ||
import SwiftUI | ||
import LaunchAtLogin | ||
import Foundation | ||
import IOKit.ps | ||
import IOKit.pwr_mgt | ||
|
||
extension ProcessInfo { | ||
/// Returns a `String` representing the machine hardware name or nil if there was an error invoking `uname(_:)` or decoding the response. | ||
/// | ||
/// Return value is the equivalent to running `$ uname -m` in shell. | ||
var machineHardwareName: String? { | ||
var sysinfo = utsname() | ||
let result = uname(&sysinfo) | ||
guard result == EXIT_SUCCESS else { return nil } | ||
let data = Data(bytes: &sysinfo.machine, count: Int(_SYS_NAMELEN)) | ||
guard let identifier = String(bytes: data, encoding: .ascii) else { return nil } | ||
return identifier.trimmingCharacters(in: .controlCharacters) | ||
} | ||
} | ||
|
||
@NSApplicationMain | ||
final class AppDelegate: NSObject, NSApplicationDelegate { | ||
|
||
//var window: NSWindow! | ||
var statusBarItem: NSStatusItem! | ||
var popover: NSPopover! | ||
|
||
func applicationWillTerminate(_ aNotification: Notification) { | ||
Helper.instance.enableSleep() | ||
Helper.instance.enableCharging() | ||
} | ||
|
||
func applicationDidFinishLaunching(_ aNotification: Notification) { | ||
|
||
let contentView = ContentView() | ||
|
||
// Create the popover | ||
let popover = NSPopover() | ||
popover.contentSize = NSSize(width: 400, height: 600) | ||
popover.behavior = .transient | ||
popover.contentViewController = NSHostingController(rootView: contentView) | ||
self.popover = popover | ||
|
||
let statusBar = NSStatusBar.system | ||
statusBarItem = statusBar.statusItem(withLength: NSStatusItem.squareLength) | ||
statusBarItem.button?.image = NSImage(named: "menubaricon")! | ||
statusBarItem.button?.action = #selector(togglePopover(_:)) | ||
|
||
Helper.instance.setPlatformKey() | ||
|
||
Helper.instance.checkHelperVersion{(foundHelper) in | ||
if(foundHelper){ | ||
print("helper found!") | ||
} | ||
else{ | ||
Helper.instance.installHelper() | ||
} | ||
} | ||
|
||
LaunchAtLogin.isEnabled = true | ||
SMCPresenter.shared.loadValue() | ||
|
||
Helper.instance.checkCharging() | ||
|
||
var actionMsg:String? | ||
|
||
Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { timer in | ||
if(Helper.instance.isInitialized){ | ||
Helper.instance.getChargingInfo { (Name, Capacity, IsCharging, MaxCapacity) in | ||
|
||
|
||
if(!PersistanceManager.instance.oldKey){ | ||
if(Capacity < SMCPresenter.shared.value){ | ||
actionMsg = "NEED TO CHARGE" | ||
if(Helper.instance.chargeInhibited){ | ||
Helper.instance.enableCharging() | ||
} | ||
Helper.instance.disableSleep() | ||
|
||
} | ||
else{ | ||
actionMsg = "IS PERFECT" | ||
if(!Helper.instance.chargeInhibited){ | ||
Helper.instance.disableCharging() | ||
} | ||
Helper.instance.enableSleep() | ||
|
||
} | ||
print("TARGET: ",SMCPresenter.shared.value, | ||
" CURRENT: ",String(Capacity), | ||
" ISCHARGING: ",String(IsCharging), | ||
" CHARGE INHIBITED: ",String(Helper.instance.chargeInhibited), | ||
" ACTION: ",actionMsg!) | ||
} | ||
else{ | ||
print("BCLM MODE ENABLED") | ||
} | ||
|
||
|
||
|
||
} | ||
DispatchQueue.main.async { | ||
Helper.instance.setStatusString() | ||
} | ||
|
||
} | ||
} | ||
|
||
} | ||
|
||
@objc func togglePopover(_ sender: AnyObject?) { | ||
popover.contentViewController?.view.window?.becomeKey() | ||
|
||
Helper.instance.setStatusString() | ||
if let button = self.statusBarItem.button { | ||
if popover.isShown { | ||
popover.performClose(sender) | ||
} else { | ||
popover.show(relativeTo: button.bounds, of: button, preferredEdge: .minY) | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"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" | ||
}, | ||
{ | ||
"filename" : "spaghetti.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
AlDente/Assets.xcassets/menubaricon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.