0

I have chosen Dark mode, under System Preferences > General > Appearance. Yet, it seems whenever starting up the computer, it switches back to Light.

I am guessing there is some "switch theme based on time of day" setting but I can't find it.

How can I have Dark mode permanently? Is there a workaround at least?

(To be really clear, the options are just Light and Dark, there is no Auto)

Mojave 10.14.2, mid 2014 MacBook Pro

2
  • Does osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to true' work on Mojave? My laptop is on Big Sur so I can't test it, but if it does, you can run that on login by creating a shell script and packaging in an Automator app.
    – quartzic
    Commented Feb 19, 2021 at 20:33
  • Yes that does seem to work! I haven't used Automator though, is there a simpler way to just run the script at login time? Commented Feb 20, 2021 at 6:47

1 Answer 1

2

Create a script to enable dark mode

This shell file will run an AppleScript command to enable Dark Mode. The first time this script is run, it may require permission to modify your system settings.

It is critical to mark the file executable with chmod +x - otherwise, it will not run and you will get a vague 'Load Failed: 5: Input/output error' from the launchctl service.

echo "osascript -e 'tell application \"System Events\" to tell appearance preferences to set dark mode to true'" > ~/AlwaysDarkMode.sh
chmod +x ~/AlwaysDarkMode.sh

Create a launch agent

Create a new text file in ~/Library/LaunchAgents titled AlwaysDarkMode.plist (or something else, if you'd like). Paste in the following contents, ensuring to change the username to your own. You cannot use relative paths like ~/AlwaysDarkMode.sh - you must write out the full path to the file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>AlwaysDarkMode.sh</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/YourUsername/AlwaysDarkMode.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Test the launch agent

Because the plist is stored in ~/Library/LaunchAgents, it should run automatically when logging in. However, it might request permissions the first time it runs, so you can load it manually with launchctl load ~/Library/LaunchAgents/AlwaysDarkMode.plist.

1
  • That's excellent, seems to work! Commented Feb 21, 2021 at 7:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .