mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
remove flexSpace
This commit is contained in:
parent
12f9220e34
commit
9ef185d214
@ -115,7 +115,6 @@ enum ItemType: Decodable {
|
|||||||
case staticButton(title: String)
|
case staticButton(title: String)
|
||||||
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
||||||
case timeButton(formatTemplate: String)
|
case timeButton(formatTemplate: String)
|
||||||
case flexSpace()
|
|
||||||
case volume()
|
case volume()
|
||||||
case brightness()
|
case brightness()
|
||||||
|
|
||||||
@ -132,7 +131,6 @@ enum ItemType: Decodable {
|
|||||||
case staticButton
|
case staticButton
|
||||||
case appleScriptTitledButton
|
case appleScriptTitledButton
|
||||||
case timeButton
|
case timeButton
|
||||||
case flexSpace
|
|
||||||
case volume
|
case volume
|
||||||
case brightness
|
case brightness
|
||||||
}
|
}
|
||||||
@ -151,8 +149,6 @@ enum ItemType: Decodable {
|
|||||||
case .timeButton:
|
case .timeButton:
|
||||||
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
||||||
self = .timeButton(formatTemplate: template)
|
self = .timeButton(formatTemplate: template)
|
||||||
case .flexSpace:
|
|
||||||
self = .flexSpace()
|
|
||||||
case .volume:
|
case .volume:
|
||||||
self = .volume()
|
self = .volume()
|
||||||
case .brightness:
|
case .brightness:
|
||||||
@ -212,8 +208,6 @@ func ==(lhs: ItemType, rhs: ItemType) -> Bool {
|
|||||||
switch (lhs, rhs) {
|
switch (lhs, rhs) {
|
||||||
case let (.staticButton(a), .staticButton(b)):
|
case let (.staticButton(a), .staticButton(b)):
|
||||||
return a == b
|
return a == b
|
||||||
case let (.flexSpace(a), .flexSpace(b)):
|
|
||||||
return a == b
|
|
||||||
case let (.appleScriptTitledButton(a, b), .appleScriptTitledButton(c, d)):
|
case let (.appleScriptTitledButton(a, b), .appleScriptTitledButton(c, d)):
|
||||||
return a == c && b == d
|
return a == c && b == d
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,6 @@ extension ItemType {
|
|||||||
return "com.toxblh.mtmr.appleScriptButton."
|
return "com.toxblh.mtmr.appleScriptButton."
|
||||||
case .timeButton(formatTemplate: _):
|
case .timeButton(formatTemplate: _):
|
||||||
return "com.toxblh.mtmr.timeButton."
|
return "com.toxblh.mtmr.timeButton."
|
||||||
case .flexSpace():
|
|
||||||
return "NSTouchBarItem.Identifier.flexibleSpace"
|
|
||||||
case .volume():
|
case .volume():
|
||||||
return "com.toxblh.mtmr.volume"
|
return "com.toxblh.mtmr.volume"
|
||||||
case .brightness():
|
case .brightness():
|
||||||
@ -81,9 +79,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
|
|
||||||
for item in jsonItems {
|
for item in jsonItems {
|
||||||
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
|
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
|
||||||
let identifier = item.type == ItemType.flexSpace()
|
let identifier = NSTouchBarItem.Identifier(identifierString)
|
||||||
? NSTouchBarItem.Identifier.flexibleSpace
|
|
||||||
: NSTouchBarItem.Identifier(identifierString)
|
|
||||||
itemDefinitions[identifier] = item
|
itemDefinitions[identifier] = item
|
||||||
if item.align == .left {
|
if item.align == .left {
|
||||||
leftIdentifiers.append(identifier)
|
leftIdentifiers.append(identifier)
|
||||||
@ -144,8 +140,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval, onTap: action)
|
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval, onTap: action)
|
||||||
case .timeButton(formatTemplate: let template):
|
case .timeButton(formatTemplate: let template):
|
||||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
|
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
|
||||||
case .flexSpace:
|
|
||||||
barItem = nil
|
|
||||||
case .volume:
|
case .volume:
|
||||||
barItem = VolumeViewController(identifier: identifier)
|
barItem = VolumeViewController(identifier: identifier)
|
||||||
case .brightness:
|
case .brightness:
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
"keycode": 113,
|
"keycode": 113,
|
||||||
"width": 36,
|
"width": 36,
|
||||||
},
|
},
|
||||||
{ "type": "flexSpace" },
|
|
||||||
{ "type": "volumeDown", "width": 44 },
|
{ "type": "volumeDown", "width": 44 },
|
||||||
{ "type": "volumeUp", "width": 44 },
|
{ "type": "volumeUp", "width": 44 },
|
||||||
{ "type": "previous" },
|
{ "type": "previous" },
|
||||||
|
|||||||
@ -101,11 +101,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
|
|||||||
"formatTemplate": "HH:mm" //optional
|
"formatTemplate": "HH:mm" //optional
|
||||||
```
|
```
|
||||||
|
|
||||||
- `flexSpace` – to easily split touch bar in two parts: left and right
|
|
||||||
```json
|
|
||||||
"type": "flexSpace"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Actions:
|
## Actions:
|
||||||
- `hidKey`
|
- `hidKey`
|
||||||
```json
|
```json
|
||||||
@ -183,7 +178,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
|
|||||||
},
|
},
|
||||||
"refreshInterval": 1
|
"refreshInterval": 1
|
||||||
},
|
},
|
||||||
{ "type": "flexSpace" },
|
|
||||||
{ "type": "previous", "width": 36 },
|
{ "type": "previous", "width": 36 },
|
||||||
{ "type": "play", "width": 36 },
|
{ "type": "play", "width": 36 },
|
||||||
{ "type": "next", "width": 36 },
|
{ "type": "next", "width": 36 },
|
||||||
@ -214,7 +208,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
|
|||||||
"action": "appleScript", "actionAppleScript": {"inline": "if application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with w in windows\r\t\t\trepeat with t in tabs of w\r\t\t\t\ttell t\r\t\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then --последнее условие проверяет, запущена ли музыка\r\t\t\t\t\t\tactivate\r\t\t\t\t\t\tset index of w to 1\r\t\t\t\t\t\tdelay 0.1\r\t\t\t\t\t\tset current tab of w to t\r\t\t\t\t\tend if\r\t\t\t\tend tell\r\t\t\tend repeat\r\t\tend repeat\r\tend tell\rend if"},
|
"action": "appleScript", "actionAppleScript": {"inline": "if application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with w in windows\r\t\t\trepeat with t in tabs of w\r\t\t\t\ttell t\r\t\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then --последнее условие проверяет, запущена ли музыка\r\t\t\t\t\t\tactivate\r\t\t\t\t\t\tset index of w to 1\r\t\t\t\t\t\tdelay 0.1\r\t\t\t\t\t\tset current tab of w to t\r\t\t\t\t\tend if\r\t\t\t\tend tell\r\t\t\tend repeat\r\t\tend repeat\r\tend tell\rend if"},
|
||||||
},
|
},
|
||||||
{ "type": "appleScriptTitledButton", "source": { "inline": "tell application \"Reminders\"\r\tset activeReminders to name of (reminders of list \"Напоминания\" whose completed is false)\r\tif activeReminders is not {} then\r\t\treturn first item of activeReminders\r\telse\r\t\treturn \"\"\r\tend if\rend tell" }, "refreshInterval": 30},
|
{ "type": "appleScriptTitledButton", "source": { "inline": "tell application \"Reminders\"\r\tset activeReminders to name of (reminders of list \"Напоминания\" whose completed is false)\r\tif activeReminders is not {} then\r\t\treturn first item of activeReminders\r\telse\r\t\treturn \"\"\r\tend if\rend tell" }, "refreshInterval": 30},
|
||||||
{ "type": "flexSpace" },
|
|
||||||
{ "type": "appleScriptTitledButton", "source": { "inline": "if application \"iTunes\" is running then\r\ttell application \"iTunes\"\r\t\tif player state is not stopped then return \"\"\r\tend tell\rend if\rif application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with t in tabs of windows\r\t\t\ttell t\r\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then\r\t\t\t\t\treturn \"\"\r\t\t\t\tend if\r\t\t\tend tell\r\t\tend repeat\r\tend tell\rend if\rreturn \"▶\"" }, "refreshInterval": 30, "width": 40},
|
{ "type": "appleScriptTitledButton", "source": { "inline": "if application \"iTunes\" is running then\r\ttell application \"iTunes\"\r\t\tif player state is not stopped then return \"\"\r\tend tell\rend if\rif application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with t in tabs of windows\r\t\t\ttell t\r\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then\r\t\t\t\t\treturn \"\"\r\t\t\t\tend if\r\t\t\tend tell\r\t\tend repeat\r\tend tell\rend if\rreturn \"▶\"" }, "refreshInterval": 30, "width": 40},
|
||||||
{ "type": "volumeDown", "width": 44 },
|
{ "type": "volumeDown", "width": 44 },
|
||||||
{ "type": "volumeUp", "width": 44 },
|
{ "type": "volumeUp", "width": 44 },
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
},
|
},
|
||||||
"refreshInterval": 30
|
"refreshInterval": 30
|
||||||
},
|
},
|
||||||
{ "type": "flexSpace" },
|
|
||||||
{
|
{
|
||||||
"type": "appleScriptTitledButton",
|
"type": "appleScriptTitledButton",
|
||||||
"source": {
|
"source": {
|
||||||
|
|||||||
@ -40,7 +40,6 @@
|
|||||||
},
|
},
|
||||||
"refreshInterval": 1
|
"refreshInterval": 1
|
||||||
},
|
},
|
||||||
{ "type": "flexSpace" },
|
|
||||||
{ "type": "play", "width": 36 },
|
{ "type": "play", "width": 36 },
|
||||||
{ "type": "next", "width": 36 },
|
{ "type": "next", "width": 36 },
|
||||||
{ "type": "sleep", "width": 36 },
|
{ "type": "sleep", "width": 36 },
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user