Throughout the day, I find myself toggling between Light and Dark modes. This evening I wrote up a shell script to keep OS X 📖 , Emacs 📖 , and my Terminal synchronized.
I named the script
dark. Now, from the command-line, I can type dark to switch between Light and Dark mode.
Below is a copy of that script:
#!/bin/sh # This script toggles the Operating System, Terminal, and Emacs # themes. It uses the state of the Operating System to determine # if the terminal and Emacs should be "dark" or "light". # First, tell OS-x to toggle dark mode. osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode' # Second, determine what is the newly set appearance. appearance=`defaults read -g AppleInterfaceStyle 2>/dev/null` if [ -z "$appearance" ] then # No value for AppleInterfaceStyle, so the OS has us in light # mode, proceed accordingly. sh $HOME/.config/base16-shell/scripts/base16-google-light.sh editor --eval "(disable-theme 'modus-vivendi)" \ --eval "(modus-operandi-theme-load)" 1> /dev/null else # AppleInterfaceStyle is set, and that means we're now in "Dark" # mode. sh $HOME/.config/base16-shell/scripts/base16-google-dark.sh editor --eval "(disable-theme 'modus-operandi)" \ --eval "(modus-vivendi-theme-load)" 1> /dev/null fi