Quickly toggle True Tone, Night Shift, Grayscale, and Dark Mode via AppleScript #

Especially handy for switching between color and E Ink monitors. Paste into Script Editor and export as a Run-only application. Launch via Spotlight, Alfred, etc. Tested under macOS Catalina 10.15.7.

-- toggle True Tone, Night Shift, Grayscale, and Dark Mode

quit application "System Preferences"

-- True Tone & Night Shift

tell application "System Preferences"
    reveal pane "Displays"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of tab group 1 of window 1
    click radio button 3 of tab group 1 of window 1
    click checkbox 1 of tab group 1 of window 1
end tell

-- Grayscale
-- assumes that user has hitherto set "Filter type:" to "Grayscale" in Accessibility > Display > Color Filters

tell application "System Preferences"
    reveal anchor "Seeing_ColorFilters" of pane "Accessibility"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Accessibility"
    click the checkbox "Enable Color Filters" of tab group 1 of group 1
end tell

quit application "System Preferences"

-- Dark Mode

tell application "System Events"
    tell appearance preferences
        set dark mode to not dark mode
    end tell
end tell

-- thanks to:
-- marshallhiens: https://discussions.apple.com/thread/251336894?answerId=252595525022#252595525022
-- cfriend: https://forum.keyboardmaestro.com/t/toggle-night-shift/11175
-- Tyler: https://stackoverflow.com/a/58469753
-- MirRelevant: https://www.reddit.com/r/mac/comments/8oztql/how_to_quickly_switch_between_light_and_dark_mode/

/mac | Feb 07, 2021


Subscribe or visit the archives.