Skip to content

Instantly share code, notes, and snippets.

@mutsune
Created January 17, 2019 04:37
Show Gist options
  • Save mutsune/925de861a8a57cc8fe6c370df98d0ece to your computer and use it in GitHub Desktop.
Save mutsune/925de861a8a57cc8fe6c370df98d0ece to your computer and use it in GitHub Desktop.
enable/disable Dark Mode scripts
function enable_darkmode() {
set_darkmode "$1" "no"
}
function disable_darkmode() {
set_darkmode "$1" "yes"
}
function set_darkmode() {
app="$1"
identifier="$(osascript -e "id of app \"${app}\"")"
if [[ "${identifier}" == "" ]]; then
echo "Unknown app: ${app}" >&2
exit 1
fi
osascript -e "tell application \"${app}\" to quit"
defaults write "${identifier}" NSRequiresAquaSystemAppearance -bool "$2"
osascript -e "tell application \"${app}\" to activate"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment