mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
exit touchbar implemented
This commit is contained in:
parent
1c45ca13a3
commit
c0401ce83d
@ -39,6 +39,7 @@ class SupportedTypesHolder {
|
||||
typealias ParametersDecoder = (Decoder) throws ->(item: ItemType, action: ActionType)
|
||||
private var supportedTypes: [String: ParametersDecoder] = [
|
||||
"brightnessUp": { _ in return (item: .staticButton(title: "🔆"), action: .keyPress(keycode: 113)) },
|
||||
"exitTouchbar": { _ in return (item: .staticButton(title: "exit"), action: .exitTouchbar) },
|
||||
]
|
||||
|
||||
static let sharedInstance = SupportedTypesHolder()
|
||||
@ -65,7 +66,7 @@ enum ItemType: Decodable {
|
||||
case refreshInterval
|
||||
}
|
||||
|
||||
private enum ItemTypeRaw: String, Decodable {
|
||||
enum ItemTypeRaw: String, Decodable {
|
||||
case staticButton
|
||||
case appleScriptTitledButton
|
||||
}
|
||||
@ -90,6 +91,7 @@ enum ActionType: Decodable {
|
||||
case hidKey(keycode: Int)
|
||||
case keyPress(keycode: Int)
|
||||
case appleSctipt(source: String)
|
||||
case exitTouchbar
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case action
|
||||
|
||||
@ -99,17 +99,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
return CustomButtonTouchBarItem(identifier: identifier, title: title, onTap: action)
|
||||
case .appleScriptTitledButton(source: let source, refreshInterval: let interval):
|
||||
return AppleScriptTouchBarItem(identifier: identifier, appleScript: source, interval: interval)
|
||||
case .exitTouchbar:
|
||||
return CustomButtonTouchBarItem(identifier: identifier, title: "exit", onTap: action)
|
||||
}
|
||||
|
||||
switch identifier {
|
||||
case .escButton:
|
||||
return CustomButtonTouchBarItem(identifier: identifier, title: "esc", key: ESCKeyPress())
|
||||
case .dismissButton:
|
||||
let item = NSCustomTouchBarItem(identifier: identifier)
|
||||
item.view = NSButton(title: "exit", target: self, action: #selector(dismissTouchBar))
|
||||
return item
|
||||
|
||||
case .brightUp:
|
||||
return CustomButtonTouchBarItem(identifier: identifier, title: "🔆", key: BrightnessUpPress())
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
[
|
||||
{ "type": "brightnessUp" }
|
||||
|
||||
{ "type": "brightnessUp" },
|
||||
{ "type": "exitTouchbar" },
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user