1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-11 09:28:38 +00:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Fedor Zaitsev 2020-05-13 16:40:56 -07:00
commit 4cdf476dd6
7 changed files with 30 additions and 50 deletions

View File

@ -1,4 +1,4 @@
name: Swift
name: Build-and-test
on: [push, pull_request]

View File

@ -1,4 +1,4 @@
name: Swift
name: Publish unsign version
on:
push:
@ -8,7 +8,7 @@ on:
- "v*"
jobs:
test:
Build-and-release:
runs-on: macOS-latest
steps:
@ -28,4 +28,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 || true
- name: GitHub Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: Release/MTMR*.dmg

View File

@ -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: "")

View File

@ -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)

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.25</string>
<key>CFBundleVersion</key>
<string>402</string>
<string>385</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View File

@ -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"
}

View File

@ -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: