Sometimes, when waking from sleep, BTT is not working… it's running, but there's nothing on the TouchBar, and in those instances I have to restart BTT. However, I have a wake-up shell script anyway, so I would like to restart BTT at every wake, just to be sure. So it would be great to have AppleScript support extended for other BTT functions, in this case "Restart", so I can execute osascript -e 'tell application "BetterTouchTool" to restart'
at every wake.
I would also like this feature, for similar reasons (BTT occasionally has an issue and needs to be restarted).
I usually just use these shell commands:
killall BetterTouchTool && killall BTTRelaunch
open -a "BetterTouchTool"
@Andreas_Hegenberg - I would like to know: are there important "cleanup" actions that I'm preventing by restarting in such a forceful way? Is this bad?
I have utilized the following 2 Applescripts, but I usually just opt for the shell commands above:
Applescript 1
This one has a loop, which I suppose is risky as I run this in a background process. Plus, it sometimes (but somehow not always!) fails to quit the process.
set appName to "BetterTouchTool"
tell application appName to quit
repeat
tell application "System Events"
if appName is not in (name of application processes) then exit repeat
end tell
do shell script "sleep 0.5"
end repeat
tell application appName to launch
and
Applescript 2
This one frequently (but somehow not always!) fails to find the menu item unless the BTT window is open.
tell application "System Events"
tell application "BetterTouchTool"
activate
end tell
tell process "BetterTouchTool"
set frontmost to true
click menu item "Restart BetterTouchTool" of menu "BetterTouchTool" of menu bar 1
end tell
end tell
2 Likes
Applescript 1 working great, thank you.