dotfiles/bin/bin/toggle-color-mode

31 lines
762 B
Bash
Executable file

#!/bin/bash
color_file=$HOME/.config/$USER/color.yml
if ! test -f $color_file; then
mkdir -p $HOME/.config/$USER
echo light > $color_file
fi
old_color=$(cat $color_file)
if [[ $old_color == "dark" ]]; then
new_color=light
else
new_color=dark
fi
alacritty=$HOME/.config/alacritty/
ln -sf $alacritty/themes/$new_color.toml $alacritty/theme.toml
# Alacritty does not notice update of imported symlink
touch $alacritty/alacritty.toml
echo $new_color > $color_file
if tmux info &> /dev/null; then
for pane_info in $(tmux list-panes -a -F '#{pane_id}-#{pane_current_command}'); do
IFS=- read pane cmd <<< "$pane_info"
if [[ $cmd == "vim" || $cmd == "nvim" ]]; then
tmux send-keys -t $pane ":lua ChangeBackground()" ENTER
fi
done
fi