How to automate darkmode!

Hey Guys!

I love the new Darkmode, but I spent maybe 20 min trying to find the setting to schedule it before I realised it does not exist. But I liked the idea of dark mode automatically turning on around eight or nine and turning off at around seven in the morning.

So I built an Automator script to do it for me, it’s super easy.

Open up Automator and choose “Calendar alarm” and paste :

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

Then copy the calendar alarm, cause you need to have two. Set one alarm at the time you want dark mode to turn on and one when you want it to turn off.

I did one more thing, cause I realised it would be convenient to quickly turn dark mode off and on and you could just bind the script to a keyboard shortcut but I decided I rather use Alfred. Because I may forget a keyboard shortcut if I don’t use it very often, but remember to type dark mode to turn on/off dark mode I think I will manage :wink:

So open up Alfred preferences and navigate into workflows (you need the powerpack for this to work).
Add an input --> Keyword ( I used dark mood but you can choose Batman if you would like).
Then add an action --> Run script (Paste in the script)
Connect the input to the action

Now you can write Batman and everything gets dark!

5 Likes

This Alfred workflow has been around since Yosemite…

Cool! I was not aware that Mac OS had a dark mode before Mojave! :smiley:

All it did before Mojave was to change the menu bar and the dock. Not really a full system dark mode.

I love the Batman keyword!

A really cool (but useless) extension would be if you a) had keyboard maestro, b) had a MIDI keyboard, and c) knew how to play piano. You could then map ”na-na-na-…-na-BATMAN” too the script :grin:

That would be amazing! I only miss a MIDI keyboard, but I’m always looking for reasons to buy more tech. Could this be it?

Uncool friend - “Why do you have a MIDI keyboard, you don’t produce any music?”

Me - “Well to activate dark mode ofc…”

Haha! Another cool possible extension (to push you over the limit): play a lullaby to turn off the lights before you go to bed (if you have some kind of home automation, which, given your obvious love for gadgets, I’m assuming that you have :wink: )

Ofc I do! :smiley:

Lullaby maybe would get a bit boring after a while, or possible annoying! But maybe dimming the lights when darkmode is activated!