From ac0e44db4d9ad86fc10da80236480f9de18a52a2 Mon Sep 17 00:00:00 2001
From: Piss Man <37189791+PissMan420@users.noreply.github.com>
Date: Wed, 16 Feb 2022 14:00:28 -0500
Subject: [PATCH] Modified the way shell script are called (#430)
* Added shell detection
* Replaced deprecated object to supported version
* Updated haptic feedback.swift to support for newer mac
Added support for m1 mac
---
MTMR/HapticFeedback.swift | 1 +
MTMR/Info.plist | 2 +-
MTMR/ShellScriptTouchBarItem.swift | 6 +++++-
MTMR/SwipeItem.swift | 6 +++++-
MTMR/Widgets/VolumeViewController.swift | 6 +++---
5 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/MTMR/HapticFeedback.swift b/MTMR/HapticFeedback.swift
index 5df6c85..9e5c17f 100644
--- a/MTMR/HapticFeedback.swift
+++ b/MTMR/HapticFeedback.swift
@@ -19,6 +19,7 @@ class HapticFeedback {
0x200_0000_0100_0000, // MacBook Pro 2016/2017
0x300_0000_8050_0000, // MacBook Pro 2019/2018
0x200_0000_0000_0024, // MacBook Pro (13-inch, M1, 2020)
+ 0x200_0000_0000_0023 // MacBook Pro M1 13-Inch 2020 with 1tb
]
// 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`
diff --git a/MTMR/Info.plist b/MTMR/Info.plist
index 90a0507..078b880 100644
--- a/MTMR/Info.plist
+++ b/MTMR/Info.plist
@@ -19,7 +19,7 @@
CFBundleShortVersionString
0.27
CFBundleVersion
- 434
+ 448
LSApplicationCategoryType
public.app-category.utilities
LSMinimumSystemVersion
diff --git a/MTMR/ShellScriptTouchBarItem.swift b/MTMR/ShellScriptTouchBarItem.swift
index 13da0cc..668a4e3 100644
--- a/MTMR/ShellScriptTouchBarItem.swift
+++ b/MTMR/ShellScriptTouchBarItem.swift
@@ -78,7 +78,11 @@ class ShellScriptTouchBarItem: CustomButtonTouchBarItem {
func execute(_ command: String) -> String {
let task = Process()
- task.launchPath = "/bin/bash"
+ if let shell = getenv("SHELL") {
+ task.launchPath = String.init(cString: shell)
+ } else {
+ task.launchPath = "/bin/bash"
+ }
task.arguments = ["-c", command]
let pipe = Pipe()
diff --git a/MTMR/SwipeItem.swift b/MTMR/SwipeItem.swift
index baf7949..3142eca 100644
--- a/MTMR/SwipeItem.swift
+++ b/MTMR/SwipeItem.swift
@@ -51,7 +51,11 @@ class SwipeItem: NSCustomTouchBarItem {
if scriptBash != nil {
DispatchQueue.shellScriptQueue.async {
let task = Process()
- task.launchPath = "/bin/bash"
+ if let shell = getenv("SHELL") {
+ task.launchPath = String.init(cString: shell)
+ } else {
+ task.launchPath = "/bin/bash"
+ }
task.arguments = ["-c", self.scriptBash!]
task.launch()
task.waitUntilExit()
diff --git a/MTMR/Widgets/VolumeViewController.swift b/MTMR/Widgets/VolumeViewController.swift
index b46f0f5..6ac5945 100644
--- a/MTMR/Widgets/VolumeViewController.swift
+++ b/MTMR/Widgets/VolumeViewController.swift
@@ -10,7 +10,7 @@ class VolumeViewController: NSCustomTouchBarItem {
super.init(identifier: identifier)
var forPropertyAddress = AudioObjectPropertyAddress(
- mSelector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume,
+ mSelector: kAudioHardwareServiceDeviceProperty_VirtualMainVolume,
mScope: kAudioDevicePropertyScopeOutput,
mElement: kAudioObjectPropertyElementMaster
)
@@ -66,7 +66,7 @@ class VolumeViewController: NSCustomTouchBarItem {
var volume: Float32 = 0.5
var size: UInt32 = UInt32(MemoryLayout.size(ofValue: volume))
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
- address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
+ address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMainVolume)
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
address.mElement = AudioObjectPropertyElement(kAudioObjectPropertyElementMaster)
AudioObjectGetPropertyData(defaultDeviceID, &address, 0, nil, &size, &volume)
@@ -86,7 +86,7 @@ class VolumeViewController: NSCustomTouchBarItem {
var address: AudioObjectPropertyAddress = AudioObjectPropertyAddress()
address.mScope = AudioObjectPropertyScope(kAudioDevicePropertyScopeOutput)
address.mElement = AudioObjectPropertyElement(kAudioObjectPropertyElementMaster)
- address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMasterVolume)
+ address.mSelector = AudioObjectPropertySelector(kAudioHardwareServiceDeviceProperty_VirtualMainVolume)
return AudioObjectSetPropertyData(defaultDeviceID, &address, 0, nil, size, &inputVolume)
}