Switching Mojave's dark and light themes using touch bar
Mac OS Mojave introduces both a pretty dark mode and a way to trigger Automator scripts right from the Touch Bar. The two go together nicely:
- Open Automator and create a “Quick Action”. This should receive “no input” and have a single “Run AppleScript” action with the following content:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
- Save it, which will then land in your
~/Library/Services
folder. - In your System Preferences > Keyboard > “Customise Touch Bar…”, drag the “Quick Actions” to your Touch Bar.
And – bam! – two taps on the Touch Bar, and you toggle between light and dark.
I also tried (desperately) to switch the accent colour at the same time, but to no avail. The script below shows that there’s highlight color: orange
, but I couldn’t get this to work. I’d appreciate any help from AppleScript pros.
tell application "System Events"
tell appearance preferences
get properties
set highlight color to orange -- does nothing visually, though it does change that property :(
end tell
end tell