Toggle Dark Mode and System Wallpaper in Keyboard Maestro 9

Just been exploring some of the new functionality in Keyboard Maestro version 9 and thought I’d share the macro in the attached image that allows me to toggle the Mojave system dark mode and set the desktop wallpaper to a matching light or dark image at the press of a single function key.

I was impressed that it’s now possible to do this all in Keyboard Maestro with a few simple steps where previously it would have required an excursion to AppleScript or similar.

3 Likes

This is very cool! I tried to create this myself without the wallpaper change and it won’t work for me. I was trying to use F15 as the hotkey, and I’m pretty sure nothing else is using that already.

Did I miss a step? I’m attaching a screenshot of my settings.

Your macro looks correct and I’ve tried it using F15 and it works for me.

Is it just triggering it via function key that is failing (i.e. does it run correctly if you trigger it from the Keyboard Maestro status menu icon) ?

If so then it’s worth trying a different function key and also checking the system keyboard shortcuts for any clashes.

System Preferences > Keyboard > Shortcuts
then check through the Shortcuts for each category.

Only other thing I can think of is if you’re using a third party keyboard and Keyboard Maestro is not registering the function key correctly for some reason.

You should be able to confirm this by adding the function key trigger using the “Other…” option at the bottom of the “This hot key” menu as this allows you to add the trigger by hitting the actual key you’re trying to use.

I tried running it from the status menu icon and I actually get the spinning beach ball… which is exactly what happened when I tried to use Automator to do this same thing using some scripting I found. I am wondering now if it is my iMac Pro or something about it that isn’t allowing this toggle to happen. I can toggle Dark Mode manually from the System Settings, but that seems to be the only way for me to do it.

As for my keyboard, I am using the Apple keyboard that came with my iMac Pro.

I’m stumped. :unamused:

Yes, that does sound odd.

I’ve successfully toggled dark mode programmatically using both AppleScript and Keyboard Maestro on several different types of Mac including an iMac Pro so it definitely should work.

Possibly some sort of software or configuration issue on your particular machine.

My initial troubleshooting steps (if you haven’t tried them already) would be…

My only other thought would be if you’ve previously installed another piece of software to toggle dark mode (e.g. NightOwl) and it’s caused some sort of conflict or configuration data corruption.

Maybe others will have further suggestions.

My iMac just ran a macOS update and restarted… for some reason I had a feeling to try to run my macro again with zero changes. THIS time, I got prompted to allow KeyboardMaestro to access/edit system settings (or events)… I clicked allow and now IT WORKS!!! Including the keyboard shortcut I made!

No idea why it works all of a sudden, nor why I didn’t get the prompt to allow before, but I’m stoked that it works.

It’s still easier to use AppleScript to switch your background. I use the script when I created my video recording setup on Keyboard Maestro.