Skip to content

Instantly share code, notes, and snippets.

@AndrewWCarson
Created March 25, 2019 22:11
Show Gist options
  • Save AndrewWCarson/c897552adca91a457a20a1c4610718ac to your computer and use it in GitHub Desktop.
Save AndrewWCarson/c897552adca91a457a20a1c4610718ac to your computer and use it in GitHub Desktop.
Changes the macOS theme to Light mode in Mojave.
#!/bin/bash
# This requires the parent process to have "System Events" enabled in TCC. When
# running this from Addigy, /Library/Addigy/go-agent will need that
# whitelist.
username=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
# Do nothing if no one logged in.
if [[ "$username" != "" ]]; then
# Tell "System Events" to change to light mode.
sudo -u "$username" osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment