diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index 3420d70..4d021b6 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -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 diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift index 46e8b95..4ceccb3 100644 --- a/MTMR/TouchBarController.swift +++ b/MTMR/TouchBarController.swift @@ -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()) diff --git a/MTMR/defaultPreset.json b/MTMR/defaultPreset.json index d01eb2f..7b95cbe 100644 --- a/MTMR/defaultPreset.json +++ b/MTMR/defaultPreset.json @@ -1,4 +1,4 @@ [ - { "type": "brightnessUp" } - + { "type": "brightnessUp" }, + { "type": "exitTouchbar" }, ]