mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 17:38:38 +00:00
added sleep button
This commit is contained in:
parent
1e07deedae
commit
285fb1fb85
@ -61,6 +61,13 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
NSTouchBar.minimizeSystemModalFunctionBar(touchBar)
|
NSTouchBar.minimizeSystemModalFunctionBar(touchBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func goToSleep() {
|
||||||
|
let task = Process()
|
||||||
|
task.launchPath = "/usr/bin/pmset"
|
||||||
|
task.arguments = ["sleepnow"]
|
||||||
|
task.launch()
|
||||||
|
}
|
||||||
|
|
||||||
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
|
||||||
switch identifier {
|
switch identifier {
|
||||||
case .escButton:
|
case .escButton:
|
||||||
@ -85,6 +92,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
let script = try! String.init(contentsOf: url)
|
let script = try! String.init(contentsOf: url)
|
||||||
return AppleScriptTouchBarItem(identifier: identifier, appleScript: script, interval: 600)
|
return AppleScriptTouchBarItem(identifier: identifier, appleScript: script, interval: 600)
|
||||||
|
|
||||||
|
case .sleep:
|
||||||
|
let item = NSCustomTouchBarItem(identifier: identifier)
|
||||||
|
item.view = NSButton(title: "☕️", target: self, action: #selector(goToSleep))
|
||||||
|
return item
|
||||||
|
|
||||||
case .prev:
|
case .prev:
|
||||||
return CustomButtonTouchBarItem(identifier: identifier, title: "⏪", HIDKeycode: NX_KEYTYPE_PREVIOUS)
|
return CustomButtonTouchBarItem(identifier: identifier, title: "⏪", HIDKeycode: NX_KEYTYPE_PREVIOUS)
|
||||||
case .play:
|
case .play:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user