#!/bin/zsh toggled=false if [ "$1" = 'toggle' ]; then osascript -e 'tell app "System Events" to tell appearance preferences to set dark mode to not dark mode' fi if defaults read -g AppleInterfaceStyle | grep -q Dark; then if [ -f $LIGHTMODE_TOGGLE_FLAG_FILE ]; then echo "Dark Mode activated" rm $LIGHTMODE_TOGGLE_FLAG_FILE toggled=true fi else if [ ! -f $LIGHTMODE_TOGGLE_FLAG_FILE ]; then echo "Light Mode activated" touch $LIGHTMODE_TOGGLE_FLAG_FILE toggled=true fi fi if [ $toggled = true ]; then echo "Executing toggle" # Read updated colors source $ZDOTDIR/.zshenv # Update Alacritty colors echo "# Automatically generated color palette [bell] color = \"$JONATHANDARKER_COLOR_BG\" [colors.cursor] cursor = \"$JONATHANDARKER_COLOR_FA\" [colors.primary] background = \"$JONATHANDARKER_COLOR_BG\" foreground = \"$JONATHANDARKER_COLOR_FG\" [colors.normal] black = \"$JONATHANDARKER_COLOR_00\" red = \"$JONATHANDARKER_COLOR_01\" green = \"$JONATHANDARKER_COLOR_02\" yellow = \"$JONATHANDARKER_COLOR_03\" blue = \"$JONATHANDARKER_COLOR_04\" magenta = \"$JONATHANDARKER_COLOR_05\" cyan = \"$JONATHANDARKER_COLOR_06\" white = \"$JONATHANDARKER_COLOR_07\" [colors.bright] black = \"$JONATHANDARKER_COLOR_08\" red = \"$JONATHANDARKER_COLOR_09\" green = \"$JONATHANDARKER_COLOR_10\" yellow = \"$JONATHANDARKER_COLOR_11\" blue = \"$JONATHANDARKER_COLOR_12\" magenta = \"$JONATHANDARKER_COLOR_13\" cyan = \"$JONATHANDARKER_COLOR_14\" white = \"$JONATHANDARKER_COLOR_15\" " > $XDG_CONFIG_HOME/alacritty/.theme.toml # Trigger color scheme change in all Neovim instances find $XDG_RUNTIME_DIR/nvim.*.0 -print0 | \ xargs -t -0 -P 64 -I % \ nvim --clean --headless --server % --remote-expr \ "execute(\"colorscheme jonathandarker\")" fi