From 52758f947d4594f2ff6971a7f2bf8c8496dc1cbb Mon Sep 17 00:00:00 2001 From: Fedor Zaytsev Date: Tue, 21 Apr 2020 05:34:03 -0700 Subject: [PATCH 1/6] Fix shell crash (#297) * Updated README Added explanation for missing parameters (background, title and image) * Implemented changable icons for AppleScriptTouchBarItem AppleScriptTouchBarItem now allow to specify any number of icons which can be changed from the script. You cannot change icon from touch event. To change icon, you need to return array from your script with 2 values - title and icn name. More info in readme * Fixed error related to ShellButton When you execute Process from swift you cannot relay solely on pipe.fileHandleForReading.readDataToEndOfFile() Sometimes when I close notebook I get exception saying that you cannot access process.terminationStatus variable while process is running. Apparently it seems that this call can be finished when OS X put disks into sleep mode(?) What I did: 1. Added Process.waitUntilExit() call 2. Added timeout (equal to the update interval) Co-authored-by: Fedor Zaitsev --- MTMR/ShellScriptTouchBarItem.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MTMR/ShellScriptTouchBarItem.swift b/MTMR/ShellScriptTouchBarItem.swift index 94d51ec..4fd51f3 100644 --- a/MTMR/ShellScriptTouchBarItem.swift +++ b/MTMR/ShellScriptTouchBarItem.swift @@ -62,11 +62,19 @@ class ShellScriptTouchBarItem: CustomButtonTouchBarItem { let pipe = Pipe() task.standardOutput = pipe + + // kill process if it is over update interval + DispatchQueue.main.asyncAfter(deadline: .now() + interval) { [weak task] in + task?.terminate() + } + task.launch() let data = pipe.fileHandleForReading.readDataToEndOfFile() var output: String = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as String? ?? "" + //always wait until task end or you can catch "task still running" error while accessing task.terminationStatus variable + task.waitUntilExit() if (output == "" && task.terminationStatus != 0) { output = "error" } From 6d266394a494c4b0dc4f23e91356c5fa713b1ce8 Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Wed, 13 May 2020 23:11:45 +0100 Subject: [PATCH 2/6] Revert "More Productive Gestures (#289)" This reverts commit f61550e5107b85eb3d59dfe825d7340b235279aa. --- MTMR/AppDelegate.swift | 4 ++-- MTMR/BasicView.swift | 37 ++----------------------------------- MTMR/Info.plist | 2 +- README.md | 13 ++++--------- 4 files changed, 9 insertions(+), 47 deletions(-) diff --git a/MTMR/AppDelegate.swift b/MTMR/AppDelegate.swift index f62ed9f..f9c5084 100644 --- a/MTMR/AppDelegate.swift +++ b/MTMR/AppDelegate.swift @@ -76,7 +76,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } else { TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier) } - + AppSettings.blacklistedAppIds = TouchBarController.shared.blacklistAppIdentifiers TouchBarController.shared.updateActiveApp() updateIsBlockedApp() @@ -132,7 +132,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { let hapticFeedback = NSMenuItem(title: "Haptic Feedback", action: #selector(toggleHapticFeedback(_:)), keyEquivalent: "H") hapticFeedback.state = AppSettings.hapticFeedbackState ? .on : .off - let multitouchGestures = NSMenuItem(title: "Default Swipe Gestures", action: #selector(toggleMultitouch(_:)), keyEquivalent: "") + let multitouchGestures = NSMenuItem(title: "Volume/Brightness gestures", action: #selector(toggleMultitouch(_:)), keyEquivalent: "") multitouchGestures.state = AppSettings.multitouchGestures ? .on : .off let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "") diff --git a/MTMR/BasicView.swift b/MTMR/BasicView.swift index 5d388cb..ce30af8 100644 --- a/MTMR/BasicView.swift +++ b/MTMR/BasicView.swift @@ -10,7 +10,6 @@ import Foundation class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate { - var onefinger: NSPanGestureRecognizer! var twofingers: NSPanGestureRecognizer! var threefingers: NSPanGestureRecognizer! var fourfingers: NSPanGestureRecognizer! @@ -31,11 +30,6 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate { stackView.orientation = .horizontal view = stackView - onefinger = NSPanGestureRecognizer(target: self, action: #selector(onefingerHandler(_:))) - onefinger.numberOfTouchesRequired = 1 - onefinger.allowedTouchTypes = .direct - view.addGestureRecognizer(onefinger) - twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:))) twofingers.numberOfTouchesRequired = 2 twofingers.allowedTouchTypes = .direct @@ -63,31 +57,9 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate { legacyPrevPositions[fingers] = position case .changed: if self.legacyGesturesEnabled { - if fingers == 1 { - let prevPos = legacyPrevPositions[fingers]! - if ((position - prevPos) > 3) || ((prevPos - position) > 3) { - if position > prevPos { - GenericKeyPress(keyCode: CGKeyCode(124)).send() - } else if position < prevPos { - GenericKeyPress(keyCode: CGKeyCode(123)).send() - } - legacyPrevPositions[fingers] = position - } - } if fingers == 2 { let prevPos = legacyPrevPositions[fingers]! - if ((position - prevPos) > 50) || ((prevPos - position) > 50) { - if position > prevPos { - GenericKeyPress(keyCode: CGKeyCode(124)).send() - } else if position < prevPos { - GenericKeyPress(keyCode: CGKeyCode(123)).send() - } - legacyPrevPositions[fingers] = position - } - } - if fingers == 3 { - let prevPos = legacyPrevPositions[fingers]! - if ((position - prevPos) > 15) || ((prevPos - position) > 15) { + if ((position - prevPos) > 10) || ((prevPos - position) > 10) { if position > prevPos { HIDPostAuxKey(NX_KEYTYPE_SOUND_UP) } else if position < prevPos { @@ -96,7 +68,7 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate { legacyPrevPositions[fingers] = position } } - if fingers == 4 { + if fingers == 3 { let prevPos = legacyPrevPositions[fingers]! if ((position - prevPos) > 15) || ((prevPos - position) > 15) { if position > prevPos { @@ -118,11 +90,6 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate { } } - @objc func onefingerHandler(_ sender: NSGestureRecognizer?) { - let position = (sender?.location(in: sender?.view).x)! - self.gestureHandler(position: position, fingers: 1, state: sender!.state) - } - @objc func twofingersHandler(_ sender: NSGestureRecognizer?) { let position = (sender?.location(in: sender?.view).x)! self.gestureHandler(position: position, fingers: 2, state: sender!.state) diff --git a/MTMR/Info.plist b/MTMR/Info.plist index ae0a326..8ee6ef2 100644 --- a/MTMR/Info.plist +++ b/MTMR/Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 0.25 CFBundleVersion - 402 + 385 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/README.md b/README.md index f69f6f7..1e51a50 100644 --- a/README.md +++ b/README.md @@ -104,16 +104,11 @@ The pre-installed configuration contains less or more than you'll probably want, ## Gestures -### Default Gestures +By default you can enable basic gestures from application menu (status bar -> MTMR icon -> Volume/Brightness gestures): +- two finger slide: change you Volume +- three finger slide: change you Brightness -By default you can enable basic gestures from application menu (status bar -> MTMR icon -> Default Swipe Gestures): - -- ```one finger slide```: Move Caret -- ```two finger slide```: Move Caret with precision -- ```three finger slide```: Increase/Decrease Volume -- ```four finger slide```: Increase/Decrease Brightness - -### Custom Gestures +### Custom gestures You can add custom actions for two/three/four finger swipes. To do it, you need to use `swipe` type: From 3fc75ca8f01cc89fbb4b665265c5fadc21c67a1c Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Wed, 13 May 2020 23:22:31 +0100 Subject: [PATCH 3/6] Updated workflows. For delivery unsign app in gihub --- .github/workflows/build-test.yml | 2 +- .github/workflows/publish.yml | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index fa2af3c..d341f6c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -1,4 +1,4 @@ -name: Swift +name: Build-and-test on: [push, pull_request] diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 31cb0e7..347ff4a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,11 +1,12 @@ -name: Swift +name: Publish unsign version -on: - push: - branches: - - master - tags: - - "v*" +# on: +# push: +# branches: +# - master +# tags: +# - "v*" +on: [push, pull_request] jobs: test: @@ -28,4 +29,14 @@ jobs: - name: Build App run: xcodebuild -project "MTMR.xcodeproj" -exportArchive -archivePath Release/App.xcarchive -exportOptionsPlist export-options.plist -exportPath Release | xcpretty -c && exit ${PIPESTATUS[0]} + - name: Create DMG + run: | + cd Release + create-dmg MTMR.app + - name: GitHub Release + uses: "marvinpinto/action-automatic-releases@latest" + with: + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: Release/MTMR*.dmg.tgz From a1f64028cced747f63c7b638307c3a7737daaceb Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Wed, 13 May 2020 23:23:03 +0100 Subject: [PATCH 4/6] Correct file for release --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 347ff4a..669fc63 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -39,4 +39,4 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - files: Release/MTMR*.dmg.tgz + files: Release/MTMR*.dmg From 75df82a5675c071e5b8a10b9b7b1237ee91c5477 Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Wed, 13 May 2020 23:34:45 +0100 Subject: [PATCH 5/6] ignore sign error --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 669fc63..1ede210 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -32,7 +32,7 @@ jobs: - name: Create DMG run: | cd Release - create-dmg MTMR.app + create-dmg MTMR.app || true - name: GitHub Release uses: "marvinpinto/action-automatic-releases@latest" From b6721f0274a04751a71135ad8ddbd42c509e03a0 Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Thu, 14 May 2020 00:05:17 +0100 Subject: [PATCH 6/6] return normal trigggers in workflows --- .github/workflows/publish.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1ede210..d1b03be 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,15 +1,14 @@ name: Publish unsign version -# on: -# push: -# branches: -# - master -# tags: -# - "v*" -on: [push, pull_request] +on: + push: + branches: + - master + tags: + - "v*" jobs: - test: + Build-and-release: runs-on: macOS-latest steps: