dotfiles/scripts/.local/share/scripts/switch-theme

45 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
capitalize() {
printf '%s' "$1" | head -c 1 | tr "[:lower:]" "[:upper:]"
printf '%s' "$1" | tail -c '+2'
}
change_theme() {
sed -i "s/iceberg_$1/iceberg_$2/" ~/.config/kitty/kitty.conf
sed -i "s/bg=$1/bg=$2/" ~/.config/nvim/init.vim
sed -i "s/iceberg_$1/iceberg_$2/" ~/.dotfiles/tmux/.tmux.conf
sed -i "s/iceberg_$1/iceberg_$2/" ~/.config/zathura/zathurarc
kitty +kitten themes --reload-in=all "Iceberg $(capitalize "$2")"
tmux source-file ~/.tmux.conf
nvr --remote-send ":source ~/.config/nvim/init.vim <CR>"
}
recolor_zathura() {
instances=$(pgrep -f zathura)
temp_file=/tmp/zathura-instances
echo "$instances" >"$temp_file"
while IFS= read -r line; do
dbus-send --type="method_call" --dest=org.pwmt.zathura.PID-"$line" \
/org/pwmt/zathura org.pwmt.zathura.ExecuteCommand string:"source"
done <"$temp_file"
}
if [ $# -lt 1 ]; then
echo "Usage: switch_theme <mode>"
echo "mode: dark|light"
exit 1
fi
mode=$1
if [ "$mode" = "light" ]; then
emacsclient --eval "(load-theme 'doom-solarized-light 'no-confirm)"
change_theme dark light
recolor_zathura
else
emacsclient --eval "(load-theme 'doom-one 'no-confirm)"
change_theme light dark
recolor_zathura
fi