Enable/disable Mojave's dark mode using Siri shortcuts (and Hazel)

I’ve just had some fun constructing a solution that lets me use Shortcuts to turn Mojave’s dark mode on and off on my MacBook Pro.

It requires Hazel to be running on the Mac, monitoring the name of an empty text file in iCloud drive that the Shortcuts app can change the name of. This then runs an applescript which turns dark mode on or off.

It works well for me using either a Siri trigger “Hey Siri, lights on/off!” or from the Shortcuts widget. There’s just a short delay before dark mode is enabled or disabled while the file synced over iCloud.

There’s some basic error catching - if you ask Siri to turn dark mode off when it’s already off, it will ask you if you want to turn it on instead (and visa versa).

There are probably much simpler ways to accomplish the same thing but it was fun to make and might inspire some other people to use similar solutions for different purposes!

If you want to get it up and running:

Set up hazel and create a blank text file in iCloud drive called darkmode_off.txt (it’s worth mentioning that in the Shortcuts app, the folder it uses in iCloud drive is called "Shortcuts” but in the Finder on Mojave it still shows as "Workflow”. It works fine - I presume it’s a bug that’ll get fixed).

Then install the two shortcuts:

Dark Mode Off
Siri trigger: “lights on”

Dark Mode On
Siri trigger: “lights off”