Skip to content

Instantly share code, notes, and snippets.

@horothesun
Last active April 6, 2022 19:37
Show Gist options
  • Save horothesun/0906ac016f2175e36a077eb7ec38ace7 to your computer and use it in GitHub Desktop.
Save horothesun/0906ac016f2175e36a077eb7ec38ace7 to your computer and use it in GitHub Desktop.
Toggle Apple Sidecar display
#!/bin/bash
# Setup
#
# ln -sf `pwd`/toggle_sidecar.sh ~/bin/toggle_sidecar.sh
# Usage
#
# toggle_sidecar.sh
read -d '' TOGGLE_SIDECAR_APPLE_SCRIPT <<EOF
tell application "System Preferences"
activate
reveal pane id "com.apple.preference.displays"
delay 1
tell application "System Events" to click first pop up button of first window of application process "System Preferences"
delay 0.5
tell application "System Events" to click second menu item of first menu of first pop up button of first window of application process "System Preferences"
quit
end tell
EOF
osascript -e "$TOGGLE_SIDECAR_APPLE_SCRIPT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment