Skip to content

Commit ac0e44d

Browse files
Modified the way shell script are called (Toxblh#430)
* Added shell detection * Replaced deprecated object to supported version * Updated haptic feedback.swift to support for newer mac Added support for m1 mac
1 parent 26ad83b commit ac0e44d

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

MTMR/HapticFeedback.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class HapticFeedback {
1919
0x200_0000_0100_0000, // MacBook Pro 2016/2017
2020
0x300_0000_8050_0000, // MacBook Pro 2019/2018
2121
0x200_0000_0000_0024, // MacBook Pro (13-inch, M1, 2020)
22+
0x200_0000_0000_0023 // MacBook Pro M1 13-Inch 2020 with 1tb
2223
]
2324

2425
// you can get a plist `otool -s __TEXT __tpad_act_plist /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/Current/MultitouchSupport|tail -n +3|awk -F'\t' '{print $2}'|xxd -r -p`

MTMR/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<key>CFBundleShortVersionString</key>
2020
<string>0.27</string>
2121
<key>CFBundleVersion</key>
22-
<string>434</string>
22+
<string>448</string>
2323
<key>LSApplicationCategoryType</key>
2424
<string>public.app-category.utilities</string>
2525
<key>LSMinimumSystemVersion</key>

MTMR/ShellScriptTouchBarItem.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ class ShellScriptTouchBarItem: CustomButtonTouchBarItem {
7878

7979
func execute(_ command: String) -> String {
8080
let task = Process()
81-
task.launchPath = "/bin/bash"
81+
if let shell = getenv("SHELL") {
82+
task.launchPath = String.init(cString: shell)
83+
} else {
84+
task.launchPath = "/bin/bash"
85+
}
8286
task.arguments = ["-c", command]
8387

8488
let pipe = Pipe()

MTMR/SwipeItem.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ class SwipeItem: NSCustomTouchBarItem {
5151
if scriptBash != nil {
5252
DispatchQueue.shellScriptQueue.async {
5353
let task = Process()
54-
task.launchPath = "/bin/bash"
54+
if let shell = getenv("SHELL") {
55+
task.launchPath = String.init(cString: shell)
56+
} else {
57+
task.launchPath = "/bin/bash"
58+
}
5559
task.arguments = ["-c", self.scriptBash!]
5660
task.launch()
5761
task.waitUntilExit()

MTMR/Widgets/VolumeViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class VolumeViewController: NSCustomTouchBarItem {
1010
super.init(identifier: identifier)
1111

1212
var forPropertyAddress = AudioObjectPropertyAddress(
13-
mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume,
13+
mSelector: kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
1414
mScope: kAudioDevicePropertyScopeOutput,
1515
mElement: kAudioObjectPropertyElementMaster
1616
)
@@ -66,7 +66,7 @@ class VolumeViewController: NSCustomTouchBarItem {
6666
var volume: Float32 = 0.5
6767
var size: UInt32 = UInt32(MemoryLayout.size(ofValue: volume))
6868
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
69-
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
69+
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMainVolume)
7070
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
7171
address.mElement = AudioObjectPropertyElement(kAudioObjectPropertyElementMaster)
7272
AudioObjectGetPropertyData(defaultDeviceID, &address, 0, nil, &size, &volume)
@@ -86,7 +86,7 @@ class VolumeViewController: NSCustomTouchBarItem {
8686
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
8787
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
8888
address.mElement = AudioObjectPropertyElement(kAudioObjectPropertyElementMaster)
89-
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
89+
address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMainVolume)
9090
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &inputVolume)
9191
}
9292

0 commit comments

Comments
 (0)