From 2aa602d77d68e552daa01db0a3e8f2fc33eb3907 Mon Sep 17 00:00:00 2001 From: Serg Date: Sun, 29 Apr 2018 23:37:09 +0700 Subject: [PATCH 1/3] recreate touchbar to clear it's cache (items survive otherwise, still doing their job) --- MTMR/AppleScriptTouchBarItem.swift | 2 +- MTMR/TouchBarController.swift | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/MTMR/AppleScriptTouchBarItem.swift b/MTMR/AppleScriptTouchBarItem.swift index 183a3e2..a379a45 100644 --- a/MTMR/AppleScriptTouchBarItem.swift +++ b/MTMR/AppleScriptTouchBarItem.swift @@ -35,7 +35,7 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem { func refreshAndSchedule() { #if DEBUG - print("refresh happened") + print("refresh happened (interval \(self.interval)), self \(self.identifier.rawValue))") #endif let scriptResult = self.execute() DispatchQueue.main.async { diff --git a/MTMR/TouchBarController.swift b/MTMR/TouchBarController.swift index c9a890b..f65ec25 100644 --- a/MTMR/TouchBarController.swift +++ b/MTMR/TouchBarController.swift @@ -50,7 +50,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate { static let shared = TouchBarController() - let touchBar = NSTouchBar() + var touchBar: NSTouchBar! var itemDefinitions: [NSTouchBarItem.Identifier: BarItemDefinition] = [:] var items: [NSTouchBarItem.Identifier: NSTouchBarItem] = [:] @@ -69,6 +69,10 @@ class TouchBarController: NSObject, NSTouchBarDelegate { } func createAndUpdatePreset(jsonItems: [BarItemDefinition]? = nil) { + if let oldBar = self.touchBar { + NSTouchBar.minimizeSystemModalFunctionBar(oldBar) + } + self.touchBar = NSTouchBar() var jsonItems = jsonItems self.itemDefinitions = [:] self.items = [:] @@ -110,8 +114,11 @@ class TouchBarController: NSObject, NSTouchBarDelegate { } func loadItemDefinitions(jsonItems: [BarItemDefinition]) { + let dateFormatter = DateFormatter() + dateFormatter.dateFormat = "HH-mm-ss" + let time = dateFormatter.string(from: Date()) for item in jsonItems { - let identifierString = item.type.identifierBase.appending(UUID().uuidString) + let identifierString = item.type.identifierBase.appending(time + "--" + UUID().uuidString) let identifier = NSTouchBarItem.Identifier(identifierString) itemDefinitions[identifier] = item if item.align == .left { From 59aa113995d286fcd7f8e138d069efefc9b61f6e Mon Sep 17 00:00:00 2001 From: Toxblh Date: Sun, 29 Apr 2018 19:27:01 +0100 Subject: [PATCH 2/3] build.sh upd --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index c4c76a1..8871423 100755 --- a/build.sh +++ b/build.sh @@ -18,6 +18,7 @@ rm -r App.xcarchive # Prerequisite: npm i -g create-dmg create-dmg "${NAME}.app" -VERSION=`mdls -raw -name kMDItemVersion MTMR.app` +VERSION=`mdls -raw -name kMDItemVersion ${NAME}.app` + echo $VERSION zip -r "${NAME}v${VERSION}.zip" "${NAME}.app" From a85507c544db76cd2c5d76cdae8ae5d64daee93b Mon Sep 17 00:00:00 2001 From: Toxblh Date: Sun, 29 Apr 2018 19:44:58 +0100 Subject: [PATCH 3/3] upd Readme, upd Default --- MTMR/defaultPreset.json | 1 + README.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/MTMR/defaultPreset.json b/MTMR/defaultPreset.json index f041f37..0eb431b 100644 --- a/MTMR/defaultPreset.json +++ b/MTMR/defaultPreset.json @@ -73,6 +73,7 @@ { "type": "volumeDown", "width": 34, "align": "right" }, { "type": "volume", "width": 60, "align": "right" }, { "type": "volumeUp", "width": 34, "align": "right" }, + { "type": "inputsource", "align": "right" }, { "type": "battery", "align": "right" }, { "type": "timeButton", "align": "right" } ] diff --git a/README.md b/README.md index 8e0bdec..9add8db 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ # My TouchBar. My rules [![GitHub release](https://img.shields.io/github/release/toxblh/MTMR.svg)](https://github.com/Toxblh/MTMR/releases) +[![license](https://img.shields.io/github/license/Toxblh/MTMR.svg)](https://github.com/Toxblh/MTMR/blob/master/LICENSE) [![Total downloads](https://img.shields.io/github/downloads/Toxblh/MTMR/total.svg)](https://github.com/Toxblh/MTMR/releases/latest) ![minimal system requirements](https://img.shields.io/badge/required-macOS%2010.12.2-blue.svg)

@@ -67,6 +68,7 @@ File for customize your preset for MTMR: `open ~/Library/Application\ Support/MT - battery - currency - weather +- inputsource > Media Keys - previous