From 05fda273cd4d9282662371a5e8fe5511f397c1e7 Mon Sep 17 00:00:00 2001 From: Vini Dalvino <37189791+PissMan420@users.noreply.github.com> Date: Thu, 27 Jan 2022 16:04:40 -0500 Subject: [PATCH] Added shell detection --- MTMR/ShellScriptTouchBarItem.swift | 6 +++++- MTMR/SwipeItem.swift | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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()