Created
November 10, 2025 15:11
-
-
Save ashleyhindle/1cb878a58889becef151c298254e67b5 to your computer and use it in GitHub Desktop.
Raycast script to toggle mouse scroll direction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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