0

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!

1 Answer 1

0

I figured it out! :D

I was able to make this work by incorporating the use of keyboard shortcuts that switch both of my displays to/from the remote desktop space, and run an application I made in automator to check the current application status, and enable/disable SensibleSideButtons accordingly.

Here's the script for the application:

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 "Microsoft Remote Desktop" then
        do shell script "defaults write net.archagon.sensible-side-buttons SBFWasEnabled -bool false"
        do shell script "killall SensibleSideButtons"
    else if appName is not equal to "Microsoft Remote Desktop" then
        do shell script "defaults write net.archagon.sensible-side-buttons SBFWasEnabled -bool true"
        do shell script "open -a SensibleSideButtons"
    end if

    -- for debug, to see the active application, remove the (* *) from the following
    (* set theDialogText to "Active app is " & (appName) & "."
    display dialog theDialogText *)
    --> Result: {button returned:"OK"} 

    return {appName}
    return 2

end run

It's not quite as automated as something that would trigger based on MS RDP being the frontmost application, and I need to remember to use the shortcut to switch to the RDP space after first opening the connection (since RDP creates the space and automatically switches to it). But it's good enough! Still much better than needing to navigate up to the menu bar, open the menu, and enable/disable the SSB app anytime I switch back/forth between my Mac and RDP.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .