If you’ve upgraded to Mojave, you’ve probably tried out Dark Mode. Maybe you love it. I got over the whole idea years ago, back when you had to run hacks just to change the menu bar background. I like my light interface.
I’m not grumpy about it, but it means I have to test any UIs I create in both modes now, so obviously that needs some automation.
Dark Mode can be toggled with AppleScript via System Events.
tell application "System Events"
tell appearance preferences
set dark mode to true
end tell
end tell
With these examples you can include a Dark Mode switcher in a script, an automated test, an Alfred/Launchbar action, a Keyboard Maestro shortcut, or create a Script Editor applet for a double-clickable mode switcher.
I’m assuming normal citizens won’t have a need to toggle between the two modes frequently, but for those who do, enjoy.