NightOwl is a menu bar app to help you quickly toggle Mojave’s dark mode on and off. But I f your menu bar is already too cluttered, or if you prefer keeping your hands on the keyboard, you can set up your own tool to accomplish this instead. To do so, you need a program that can invoke an AppleScript, such as LaunchBar. I’ve set forth the steps for creating this below, but you can jump to the end of this post if you only want to download the Actions and don’t care how they’re made.
The applescript
Here’s the AppleScript you need:
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
setting up the applescript on launchbar
You now need a way to invoke that AppleScript. I prefer using LaunchBar to call the script, as opposed to a menu bar app, because I’m more efficient if I keep my hands on the keyboard. You could probably save the AppleScript as an application, and run that application using LaunchBar. I haven’t tried this method, because I’ve inserted the script directly into a LaunchBar action.
To do so, you need to open LaunchBar’s Action Editor to create your action. The best instructions I’ve seen for setting up a script in the LaunchBar Action Editor are by Brian Kammer over in the Keyboard Maestro forums, of all places. His instructions will guide you through how to run a Keyboard Maestro macro via LaunchBar. That’s fantastic (and something you should tuck away for future use), but you want to focus on the part of the instructions that explain how to set up an AppleScript in the LaunchBar Action Editor.
Start with the part of the instructions that reads, “First, invoke the Action Editor in LB.” When you get to the part of the instructions containing an AppleScript,1 use the AppleScript I’ve included above, instead of the AppleScript in the instructions. Otherwise just follow the instructions, and remember the name you gave your Action.
Invoking the Action
Once created, you invoke the Action the same way you invoke other LaunchBar actions – by calling up LaunchBar with your keyboard shortcut and typing part of the Action’s name. In my case, I named my actions “Dark Mode” and “Light Mode,” so I switch to dark mode by typing “DM” and light mode by typing “LM.”
When you do this, your Mac will switch from your current mode – dark or light – to the opposite. As a result, you really only need one LaunchBar action. I still created a duplicate with a different name, so I could have one action named Light Mode, and another named Dark Mode.
Here’s what the LaunchBar action looks like in use:
Download the Actions
If you just want to install the Actions, and not worry about how they were created, you can get them at this link.
The AppleScript mentions the Keyboard Maestro Engine, and begins with “tell Application . . .”↩
40Tech says:
@40Tech I just updated this post with the most important part – a link to download the Actions if you don’t care how they were made. Found at the very end of the post.
October 1, 2018 — 8:53 am
Marco Istasy says:
Hey! Thanks so much for this post. Do you have any actions for enabling/disabling bluetooth and wifi?
November 27, 2018 — 12:03 pm