How to Enable Dark Mode in MacOS Automatically on Schedule with Automator
Wouldn’t it be nice if you could schedule the Dark Mode theme to enable itself automatically on your Mac, perhaps in the evening hours, and on a recurring schedule? That’s exactly what this tutorial is going to show you how to do, without needing to download or use any third party apps.
Update: modern versions of macOS have automatic Dark Mode as a feature, not requiring the Automator script discussed here.
We’ll be using Automator and the Calendar app to set Dark Mode to enable itself automatically in the evening hours, then disable itself automatically in the morning hours to return to light mode. Using Dark Mode on the Mac is fantastic for working in low light situations and at night time, and so much like you can (and should) schedule Night Shift mode on the Mac, we’ll be setting Dark Mode to run on a schedule as well. This is a feature that hopefully will be baked into future versions of MacOS by default, but for the time being you can follow our guide to set the theme scheduling up yourself.
How to Enable Dark Mode Automatically on a Schedule
Before getting started, put your Mac into the regular Light mode setting.
- Open “Automator” on the Mac
- Choose to create a new “Application”
- In the Library actions, search for ‘Change System Appearance’ and drag that into the Automator workflow, then set that as “Toggle Light / Dark”
- Save the Automator application with an obvious name, like “Toggle Light or Dark Mode.app”, into an easily accessed location, like the Documents folder
- Now open the “Calendar” app in Mac OS
- Go to the “File” menu and then choose “New Calendar”, give the new Calendar an obvious name like “Dark Light Mode Toggle” (this is optional but recommended because the recurring event will show up every day on a calendar)
- Create a new Calendar event by clicking on the “+” plus button and label it something like “Toggle Dark and Light Mode”
- Double-click on the event to edit it, using the following parameters:
- starts: (todays date) at 10:00 PM (adjust if desired)
- ends: (tomorrows date) at 6:00 AM (adjust as desired)
- repeat: Every Day
- alert: Custom
- Now in the Custom alert section, choose “Open File” and select the “Toggle Light or Dark Mode.app” Automator app you created earlier, and set this to open “At time of event” then click OK
- Next create a second ‘alert’ and again choose “Custom” and to “Open File” selecting ‘Toggle Light or Dark Mode.app’ again, and set this one to open ’10 hours after start of event’ then click “OK”
- When finished, exit out of Calendar and Automator, whatever your starting event time is will be when Dark mode enables itself automatically, and the second alert after the start of the event will be when Light mode re-enables itself
While making these changes in Calendar, if you get a message about changing a recurring event, choose “All Future Events”.
That’s it, now your recurring Calendar event will trigger the Automator theme toggle app you created, adjusting between Dark mode and Light mode as the time changes.
In the example here, Dark mode is enabled for 10 hours from 10pm onward, but you can adjust that as needed. If you like using Dark Mode from 7pm until 7am, set those as the calendar events and the ‘after’ event for 12 hours later.
This trick is pretty straight forward, using the ability to launch apps and files on a schedule on the Mac with Calendar events to open the Dark/Light theme toggle app which you built yourself in Automator. Isn’t the Mac great?
By the way, you can also open the ‘Toggle Light or Dark Mode.app’ app you created in Automator at any time to quickly switch between dark and light mode, without having to enable Dark Mode through the Mac System Preferences as usual.
There are also a variety of third party tools that will match this general functionality, including NightOwl and F.lux, but if you don’t want to download anything else then the above method works just fine with what MacOS Mojave ships with by default. Hopefully scheduling Dark Mode becomes an option with Night Shift in a future macOS release, but until (or if) that happens, go ahead and use this Calendar and Automator combination approach, or another utility to gain the same effect.
Do you know of any other methods to automate dark mode and light mode on the Mac? Share with us in the comments below!
I tried this. It drove me slowly crazy until I needed to disarm it. Too many notifications and it always seemed to change in the middle of something important. I don’t like how text documents go black. Makes it really hard to see. I’ll be looking for a manual switch I can park in the dock. Should be easy enough with AppleScript, I hope.
Anyway, thanks for the instructions, Its good to try.
Also, another website has a method where you use Automator to create a script that goes in the Services menu. You can create a hotkey to activate it. It works well, but every time you use it, if you’ve never used it within the particular app that is in the foreground, you have to give the app permission. I don’t know enough about it to know whether or not there’s a security issue if you’re giving permission to, say, Safari. Also, the hotkey won’t work in Finder at first – you have to manually select the Service from the Finder>Services menu, then give Finder permission, before it will work.
It isn’t quite as nice as having a Menu Bar icon, but I like the idea of not adding one more running process, no matter how small.
The problem I have with using the Calendar method is that I just want the mode to change quietly without any banners or alerts. But I wouldn’t want it off for every Calendar event either, just for this. Also, it seemed like f I turn off banners/alerts, the mode does not change. (But it might just be coincidence, and actually related to the lockscreen issue mentioned in another reply.)
Another problem I had is that it worked fine when I scheduled it as an overnight event – say, 19:00-7:00. However, when I tried to do it the other way around, 7:00-19:00, it didn’t seem to work. It also might be due to the lockscreen issue mentioned in another reply, but I didn’t have to disable lockscreen notifications the first way.
Dark Switch is supposed to provide a Menu Bar icon to switch modes, but I couldn’t get it to launch – probably some kind of permissions issue:
https://github.com/ariestiyansyah/dark-switch/releases
I’d get the launch animation, but nothing happens after that – no Menu Bar icon, no error message, don’t see a running process, etc.
After further testing, it seems the problem I’m having is related to the computer going to sleep. Every time it does, when I wake the computer, it toggles light/dark. Something isn’t right with the way Calendar is handling the event.
Sorry for all the self-replies. Here’s what I could figure out:
Light/dark mode will not toggle if the computer is asleep (not sure yet if it has to go all the way to the lock screen). It will activate after you wake the computer, but only if you are still within the event time. For example, if you set the event time to 7:00-7:01, but you don’t wake your computer until 7:05, it won’t toggle.
Unfortunately, every time the computer goes to sleep, and you wake it again, if you are within the event time, it will toggle again. (Again, not sure if it has to go all the way to the lock screen or not.) What’s worse, if you schedule two alarms in one event, as this article suggests, the second alarm will extend the time where this repeated toggling due to sleep will take place. For example, if the event is 10 hours long, and if the second alarm is set to happen 10 hours after the (start of the) event, sleep will continue to toggle light/dark for 10 hours after the END of the event.
The best solution I could come up with is to create two separate events, each with one alarm. Give each event a window of a few hours, during which I’m likely to be using the computer and not let it go to sleep. Also, I created a hotkey to manually toggle light/dark, just in case there’s a non-toggle or extra toggle. It isn’t an ideal solution, but Apple didn’t give us much choice in Mojave.
Using Mojave on my rMBP 15″ 2015. Wanted to know if it’s possible to automate toggling between modes based on local sunrise and sunset. I’m not an experienced Automator user, so I hope someone knows the trick. I live in Moscow, the length of daylight here varies substantially from one season to another. Right now, the only option I have is to manually set the sunrise/sunset times in Calendar in order for the toggling to occur properly. In case someone knows the way, please share.
Wonderful, thank you. :)
The problem that I’ve had with an Automator script attached to the Calendar is that even if I put it in a different Calendar and have that Calendar not activated on my watch, my desktop, or any other device, I still get notifications on my watch every time that script runs. If you have a solution to that, please let me know.
Flux manages this pretty well with no setup: https://justgetflux.com/news/pages/macquickstart/
.. See Color Effects > OS X Dark theme at sunset
Great idea. Is there a way to automatically create events with sunrise/sunset time of each day? I can put on a spreadsheet all the times but I don’t know how to create calendar events from that data. Any help is appreciated
Thanks for the nice post
Downside of NightOwl is that their privacy policy sucks. If you’re using it then they’re sucking in a ton of information on you. I’d read their privacy policy here: https://nightowl.kramser.xyz/impressum
Thanks for sharing it
Rather than having it going on and off at set times, I would much prefer a simple switch in the menu bar. I understand that I can download the Nightowl app for that, but I do not want to download another app for something so simple, and I am disappointed that Apple did not think to do that. After all, they offer them for Bluetooth, Wifi etc..
You can put the Auto-Light-Dark.app automator script on your dock. Double click it, and it’s effectively like a switch.
Thanks for the tip. For best results, disable the display of calendar notifications on the lock screen. To do that, just open system preferences, click on notifications, then on calendar and uncheck the box next to “show notifications on lock screen”. Before I did that, I found that often the Mac switched modes twice on every alert: once while still locked and then once again after unlocking it. This resulted in having light mode when it was supposed to be dark and viceversa. Hope this helps
This was a good exercise to get me to try Automator again. And I enjoyed myself.
One thing I don’t like is that it takes up a line in Calendar. Precious little space there as it is. I use the monthly format and only have three or four things in view on any given day.
Just make a new calendar (I called mine calendar apps,) save the events in that calendar and uncheck the box.
Thanks – I’ll have to set this up for now.
I’m sure they’ll eventually build in an automated switch to and from Dark Mode – either based on time, or maybe based on ambient light.
NightOwl sits in the menubar and schedules Dark Mode and also offers a little on/off switch, it’s free and is pretty easy to use
https://nightowl.kramser.xyz/
I think I saw another one too but can’t remember the name
thanks guy :)