Quick way to enable / disable a setting on MacOS?

Don
Joined
18 Oct 2002
Posts
23,198
Location
Wargrave, UK
I need a quick way to enable or disable a setting and I can't for the life of me figure out how to do it.
The setting is Three Finger Drag which is now buried in the Accessibility preferences. I need to turn it on when I use some CAD apps so I can do a middle click and drag with the touchpad. I then want it off when I'm not using CAD apps as it interferes with some of the gestures I use in BTT.

I've tried making a script that uses defaults but even though I can get it to run and change the setting, it doesn't actually cause the setting to be enabled. This is my script:

defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true


I tried messing with PlistBuddy

/usr/LibExec/PlistBuddy -c "Set :TrackpadThreeFingerDrag.plist bool true" com.apple.driver.AppleBluetoothMultitouch.trackpad.plist

Doesn't work either.

Any ideas?
 
Is 'TrackpadThreeFingerDrag' a boolean rather than a integer?

Just that the default command can incorrectly report a type, especially with integers and booleans, so check with PlistBuddy as that should tell you exactly the type for a given key or try the commands with integers instead, ie -
Code:
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -int 1
defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -int 1


Also double check the key names, as Apple has a habit of renaming them between releases.
 
Definitely a boolean. The result of /usr/libexec/PlistBuddy -x -c "Print" Library/Preferences/com.apple.AppleMultitouchTrackpad.plist

<key>TrackpadThreeFingerDrag</key>
<false/>

The plist is correct because I see those two plists pop to the top of the recently changed list in Finder when I change the setting manual. Dumping the plists to a file with PlistBuddy before and after changing the setting and then doing a diff lists that as the only changed item.
 
OK I sussed it. Unfortunately what I'm trying to do isn't possible due to MacOS caching the plists. It only re-reads them back when either a preferences pane adjusts them or you log out and back in again.
 
Well, after a lot of learning and messing about; I did it with Apple Script which I call with a Shortcut from my menu bar.

Here is the code for reference:

Code:
tell application "System Preferences"
    activate
    set the current pane to pane id "com.apple.preference.universalaccess"
    delay 1
    reveal anchor "Mouse" of pane id "com.apple.preference.universalaccess"
    tell application "System Events" to tell process "System Preferences"
        click button "Trackpad Options…" of tab group 1 of group 1 of window "Accessibility"
        click checkbox "Enable dragging" of sheet 1 of window "Accessibility"
        click pop up button 1 of sheet 1 of window "Accessibility"
        key code 125
        key code 125
        key code 36
        key code 36
    end tell
end tell
 
Back
Top Bottom