Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm looking to make a script that quickly toggles the Natural scrolling settings, so I need a way to do it from the command line.

I think I found the correct defaults command, but I'm not sure how to apply it without logging out. Here is the command I'm using:

defaults write ~/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool

share|improve this question

1 Answer 1

The same setting is visible in the Magic Mouse and Trackpad panes. This works if you have a Magic Mouse connected (but not if you do not):

osascript -e 'tell application "System Preferences"
    reveal anchor "mouseTab" of pane id "com.apple.preference.mouse"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of window 1
end tell
quit application "System Preferences"'

This works if you have a trackpad:

osascript -e 'tell application "System Preferences"
  reveal anchor "trackpadTab" of pane id "com.apple.preference.trackpad"
end tell

tell application "System Events" to tell process "System Preferences"
    click radio button 2 of tab group 1 of window 1
    click checkbox 1 of tab group 1 of window 1
end tell

quit application "System Preferences"'

nb: the "Accessibility Inspector" tool that comes with Xcode can be used to locate UI items to click on.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.