Skip to content

Instantly share code, notes, and snippets.

@ashleyhindle
Created November 10, 2025 15:11
Show Gist options
  • Select an option

  • Save ashleyhindle/1cb878a58889becef151c298254e67b5 to your computer and use it in GitHub Desktop.

Select an option

Save ashleyhindle/1cb878a58889becef151c298254e67b5 to your computer and use it in GitHub Desktop.
Raycast script to toggle mouse scroll direction
#!/bin/bash
# Required parameters
# @raycast.schemaVersion 1
# @raycast.title Toggle mouse scroll direction
# @raycast.mode silent
#
# Optional parameters:
# @raycast.packageName CTG
open 'x-apple.systempreferences:com.apple.Trackpad-Settings.extension?ScrollAndZoom'
osascript <<'EOF'
on run argv
tell application "System Events"
my waitForRef(me, process "System Settings")
tell process "System Settings"
my waitForWindow(me)
my waitForRef(me, scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1)
click checkbox 1 of group 1 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
end tell
end tell
tell application "System Settings" to quit
end run
on waitForWindow(scriptRef)
set attemptCount to 0
repeat while attemptCount < 80
tell application "System Events"
tell process "System Settings"
set windowCount to count of windows
if windowCount > 0 then
return true
end if
end tell
end tell
delay 0.01
set attemptCount to attemptCount + 1
end repeat
error "Window not found in time"
end waitForWindow
on waitForRef(scriptRef, elementRef)
set attemptCount to 0
set stableCount to 0
set requiredStableChecks to 1
repeat while attemptCount < 80
tell application "System Events"
try
if exists elementRef then
set stableCount to stableCount + 1
if stableCount ≥ requiredStableChecks then
return true
end if
else
set stableCount to 0
end if
on error
set stableCount to 0
end try
end tell
delay 0.01
set attemptCount to attemptCount + 1
end repeat
error "Stable element not found in time"
end waitForRef
EOF
value=$(defaults read NSGlobalDomain com.apple.swipescrolldirection 2>/dev/null || echo "0")
[[ "$value" == "1" ]] && echo "Scrolling now natural" || echo "Scrolling now traditional"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment