How to add a Dark Mode toggle to the MacBook Pro’s Touch Bar

By

The homemade Dark Mode button lets you toggle between Dark Mode and the MacBook Pro's regular appearance, right from your Touch Bar.
The homemade Dark Mode button.
Photo: Charlie Sorrel/Cult of Mac

The Mac’s Dark Mode isn’t bad. It’s definitely a better view when quickly checking something on your Mac late in the evening. But unless you have it set to switch automatically, toggling Dark Mode on and off is a pain. So, with a shiny new MacBook Pro in front of me, I decided to put the Touch Bar to use.

Did you know you can add your own buttons to the Touch Bar? You can, and it’s totally rad.

Toggle Mac Dark Mode with Automator and the Touch Bar

For getting work done, I prefer light mode. I can’t read reversed-out, light-on-dark text very easily. I want to be able to switch in and out of Mac Dark Mode as quickly as possible. This tip, then, is perfect. I put a button in the Touch Bar that runs an Automator action, and that action runs an AppleScript that does the work.

It sounds complicated, but it’s not. Let’s check it out.

Quick Actions in the Touch Bar

The MacBook Pro’s Touch Bar can run Automator actions. You just drop them into the right spot in the System Preferences app, and they’ll show up. After you add them, you can reach them by tapping the Quick Actions button in the Touch Bar’s Control Strip. It looks like this:

The Quick Actions button looks like a little signpost.
The Quick Actions button looks like a little signpost.
Photo: Cult of Mac

Tap that, and your Quick Actions will fill the Touch Bar:

I have three Quick Actions installed at the moment.
I have three Quick Actions installed at the moment.
Photo: Cult of Mac

How to add Quick Actions to your Touch Bar

Toggle Quick Actions here.
You can toggle Quick Actions here.
Photo: Cult of Mac

Before we get to the Dark Mode toggling action itself, let’s see how to install a Quick Action to the Touch Bar. Open up the System Preferences app, and click on the Extensions section. Then, in the sidebar, choose Touch Bar. In this panel, you’ll see all your available Quick Actions. To add one to the Touch Bar, just check the box next to it.

But where do these Quick Actions come from?

Finally, the Dark Mode button Automator action

Quick Actions are a macOS Mojave/Catalina feature that lets you add Automator actions to the Finder’s preview panel, and to the Touch Bar. To create one, open up the Automator app, and create a new workflow, either with ⌘N, or from File>New in the menu bar. Then, click on the Quick Action option:

Create a Mac Quick Action here.
Create a Quick Action here.
Photo: Cult of Mac

Any Quick Action you create in Automator will show up in the Quick Actions panel we saw earlier. For now, let’s create the Dark Mode toggle. You can just copy this:

The Dark Mode toggle action is just a simple wrapper for an AppleScript.
The Dark Mode toggle action is just a simple wrapper for an AppleScript.
Photo: Cult of Mac

Pretty much all you have to do is set the action to receive nothing (using the top left dropdown menu), customize the icon, and add one step to the workflow. This step is the Run AppleScript action. Drag it in, and paste in this script:

on run input, parameters
tell application "System Events"
tell appearance preferences
set dark mode to not dark mode
end tell
end tell
return input
end run

Click the little hammer icon to tidy it all up after you’re done. Save the Quick Action, give it a name, and then add it to the Touch Bar, as detailed above.

Any action

Now, whenever you want to toggle between Dark Mode and the Mac’s regular light appearance, just tap the signpost icon in your Touch Bar’s Control Strip, then tap your new toggle button. That’s it. Light/Dark Mode toggling is just two taps away, at any time.

And remember, you can add any other Mac Quick Actions to the Touch Bar in the same way. We’ll probably do a roundup of those pretty soon, so if you have any good ones, let us know.

Newsletters

Daily round-ups or a weekly refresher, straight from Cult of Mac to your inbox.

  • The Weekender

    The week's best Apple news, reviews and how-tos from Cult of Mac, every Saturday morning. Our readers say: "Thank you guys for always posting cool stuff" -- Vaughn Nevins. "Very informative" -- Kenly Xavier.