Skip to content

Instantly share code, notes, and snippets.

@jhochwald jhochwald/AddLauncher.sh
Last active Sep 27, 2018

Embed
What would you like to do?
Automate macOS Mojaves dark mode - https://hochwald.net/automate-macos-mojaves-dark-mode/
# Load then both
launchctl load ~/Library/LaunchAgents/Set-DarkMode.plist
launchctl load ~/Library/LaunchAgents/Set-LightMode.plist
# Unload
launchctl unload ~/Library/LaunchAgents/Set-DarkMode.plist
launchctl unload ~/Library/LaunchAgents/Set-LightMode.plist
<?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>net.enatec.Set-DarkMode</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin</string>
</dict>
<key>Label</key>
<string>Set Dark Mode</string>
<key>ProgramArguments</key>
<array>
<string>/Users/josh/bin/Set-DarkMode.sh</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>23</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</array>
</dict>
</plist>
-- turn on Dark Mode on macOS
tell application "System Events"
tell appearance preferences
set dark mode to true
end tell
end tell
#!/usr/bin/env bash
# Load some defaults
. /etc/bashrc
PATH=/usr/local/bin:/usr/local/sbin/:/var/root/bin/:$PATH
export PATH
osascript ~/bin/Set-DarkMode.scpt > /dev/null 2>&1
exit 0
<?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>net.enatec.Set-LightMode</string>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin</string>
</dict>
<key>Label</key>
<string>Set Light Mode</string>
<key>ProgramArguments</key>
<array>
<string>/Users/josh/bin/Set-LightMode.sh</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>6</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</array>
</dict>
</plist>
-- turn on Dark Mode on macOS
tell application "System Events"
tell appearance preferences
set dark mode to false
end tell
end tell
#!/usr/bin/env bash
# Load some defaults
. /etc/bashrc
PATH=/usr/local/bin:/usr/local/sbin/:/var/root/bin/:$PATH
export PATH
osascript ~/bin/Set-LightMode.scpt > /dev/null 2>&1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.