Skip to content

Instantly share code, notes, and snippets.

@pierd
Last active March 5, 2024 08:54
Show Gist options
  • Save pierd/9277a3e2edf3cbc4257cc4176e9c236e to your computer and use it in GitHub Desktop.
Save pierd/9277a3e2edf3cbc4257cc4176e9c236e to your computer and use it in GitHub Desktop.

macOS toggle-natural-scrolling helper

There's only one setting for Natural Scrolling in macOS. On the surface there are two (one for Trackpad and one for Mouse) but changing one changes the other.

I like to have Natural Scrolling on for Trackpad and off for Mouse. This is where this script comes in handy.

Tested on Sonoma. Tried a bunch of different scripts but this is the one that worked so I've put it here.

Setup

  1. Open script in Script Editor.
  2. File -> Export... as an application in Applications (choose whatever name you like).
  3. In System Settings on to "Privacy & Security" and add the new application in "Accessibility" section.

Now you can run this application and it will toggle the Natural Scrolling setting in Trackpad System Settings.

try
tell application "System Settings"
activate
end tell
delay 1
if application "System Settings" is running then
tell application "System Events"
tell application process "System Settings"
click menu item "Trackpad" of menu "View" of menu bar item "View" of menu bar 1
delay 0.5
click radio button 2 of tab group 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
delay 0.3
click checkbox "Natural scrolling" of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window "Trackpad"
click menu item "Close" of menu "File" of menu bar item "File" of menu bar 1
end tell
end tell
end if
on error errMsg number errNum
display alert "Error " & errNum & ": " & errMsg
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment