diff --git a/MTMR/ItemsParsing.swift b/MTMR/ItemsParsing.swift index ea88c28..95a77b0 100644 --- a/MTMR/ItemsParsing.swift +++ b/MTMR/ItemsParsing.swift @@ -46,6 +46,14 @@ class SupportedTypesHolder { "previous": { _ in return (item: .staticButton(title: "⏪"), action: .hidKey(keycode: NX_KEYTYPE_PREVIOUS)) }, "play": { _ in return (item: .staticButton(title: "⏯"), action: .hidKey(keycode: NX_KEYTYPE_PLAY)) }, "next": { _ in return (item: .staticButton(title: "⏩"), action: .hidKey(keycode: NX_KEYTYPE_NEXT)) }, + "weather": { decoder in + enum CodingKeys: String, CodingKey { case refreshInterval } + let container = try decoder.container(keyedBy: CodingKeys.self) + let interval = try container.decodeIfPresent(Double.self, forKey: .refreshInterval) + let scriptURL = Bundle.main.url(forResource: "weather", withExtension: "scpt")! + let item = ItemType.appleScriptTitledButton(source: try! String(contentsOf: scriptURL), refreshInterval: interval ?? 1800.0) + return (item: item, action: .none) + }, ] static let sharedInstance = SupportedTypesHolder() diff --git a/MTMR/defaultPreset.json b/MTMR/defaultPreset.json index 5bc3764..56e7890 100644 --- a/MTMR/defaultPreset.json +++ b/MTMR/defaultPreset.json @@ -10,4 +10,5 @@ { "type": "next" }, { "type": "volumeUp" }, { "type": "volumeUp" }, + { "type": "weather", "refreshInterval": 1800 }, ] diff --git a/README.md b/README.md index 060ee7a..14eb9cc 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,10 @@ My the idea is to create the program like a platform for plugins for customizati - [x] First the weather plugin - [x] Find how to open full-screen TouchBar without the cross and stripe menu - [x] Find how to add haptic feedback -- [ ] JSON or another approch for save preset and plugins maybe in `~/mtmr` +- [x] JSON or another approch for save preset, maybe in `~/Library/Application Support/MTMR/` - [ ] Layout: [always left, NSSliderView for center, always right] - [ ] Custom buttons size, actions by click in settings +- [ ] Overwrite default values from item types (e.g. title for brightness) - [ ] Add icon and menu in StatusBar - [ ] Hide from Dock - [ ] Status menu: "preferences", "quit"