I've tried to make this script/app work myself, but can't figure it out. Basically, I am trying to enable/disable the functionality of SensibleSideButtons (SSB) based on whether or not I am actively using VPN/RDP (Microsoft Remote Desktop) to use my PC at work.
When using my Mac, I need SSB enabled in order to get the mouse4/mouse5 thumb buttons on my Logitech MX518 mouse to work properly for back/forward navigation in Finder or Chrome. But when using my PC at work via VPN/RDP, with SSB enabled, these buttons won't work for navigation on the PC in Explorer or Chrome.
I discovered that the preference file for the SSB app is ~/Library/Preferences/net.archagon.sensible-side-buttons.plist, and I know the value that is changed when the app is enabled/disabled (SBFWasEnabled ).
Here's the script I have so far for the app I'm trying to make to either continuously monitor the active/frontmost application, or to run every time I switch applications (which would be more efficient) to control the SBB app being enabled/disabled.
on run {input, parameters}
tell application "System Events"
set frontmostProcess to first process where it is frontmost
set appName to name of frontmostProcess
end tell
if appName is equal to "Finder" then
do shell script "sudo defaults write net.archagon.sensible-side-buttons SBFWasEnabled -bool true" with administrator privileges
else if appName is not equal to "Finder" then
do shell script "sudo defaults write net.archagon.sensible-side-buttons SBFWasEnabled -bool false" with administrator privileges
end if
return {appName}
return 2
end run
After I save this as an application using Script Editor, when I try to run it, I see the following error:
The application “SSB_MRD_control.app” can’t be opened.
Hopefully someone here can let me know what I am missing or doing wrong so I can get this working properly.
Thank you in advance for anyone who can help me out with this!