dotfiles/.local/share/scripts/theme-selector.sh

54 lines
1.7 KiB
Bash
Raw Normal View History

2024-02-17 14:18:08 +00:00
#!/bin/bash
# defaults
2024-02-23 21:12:18 +00:00
theme_options=(
"catppuccin-dark"
"gruvbox-material-dark"
"catppuccin-light"
"gruvbox-material-light"
)
2024-02-17 14:18:08 +00:00
2024-02-23 21:12:18 +00:00
# rofi script to get what theme to use
2024-03-14 22:36:48 +00:00
chosen=$(printf '%s\n' "${theme_options[@]}" | rofi -dmenu -p "Theme" -theme-str "configuration {show-icons:false;}")
if [[ $chosen == "-" ]]; then
2024-03-14 19:52:10 +00:00
exit 1
fi
theme=$(echo "${chosen}" | rev | cut -d- -f2- | rev)
2024-02-17 14:18:08 +00:00
background=$(echo "${chosen}" | awk -F'-' '{print $NF}')
2024-02-17 14:18:08 +00:00
# change rofi theme
2024-03-14 19:52:10 +00:00
rofi_conf=~/.config/rofi/config.rasi
rofi_theme_check="${rofi_conf}"/"${chosen}".rasi
if [[ -f $rofi_theme_check ]]; then
echo "Rofi Theme ${chosen} not found"
exit 1
fi
sed -i "s/\(@import \"~\/.config\/rofi\/colors\/\).*/\1${theme}-${background}.rasi\"/" $rofi_conf
2024-02-17 14:18:08 +00:00
# change neovim theme
sed -i "s/\(local color = \).*/\1\"${theme}\"/" ~/.config/nvim/lua/tsousa/plugins/colorscheme.lua
sed -i "s/\(local background = \).*/\1\"${background}\"/" ~/.config/nvim/lua/tsousa/plugins/colorscheme.lua
2024-02-23 21:12:18 +00:00
2024-02-17 14:18:08 +00:00
# change xresources
2024-02-23 21:12:18 +00:00
xresources_themes=".Xresources.d"
2024-03-14 19:52:10 +00:00
sed -i "s/#include \".*\"/#include \"${xresources_themes}\/${theme}-${background}\"/" ~/.Xresources
xrdb ~/.Xresources
2024-02-23 21:12:18 +00:00
2024-03-14 19:52:10 +00:00
# change tmux
# add case for when tmux is not running
tmux_background=$(grep "^*.background" ~/"${xresources_themes}"/"${theme}"-"${background}" | awk '{print $2}')
tmux_foreground=$(grep "^*.foreground" ~/"${xresources_themes}"/"${theme}"-"${background}" | awk '{print $2}')
sed -i "s/set -g status-style 'bg=.* fg=.*'/set -g status-style 'bg=${tmux_background} fg=${tmux_foreground}'/" ~/.config/tmux/tmux.conf
tmux source "$HOME/.config/tmux/tmux.conf"
# change dunst
# change fish
2024-03-14 22:36:48 +00:00
fish -c "echo 'y' | fish_config theme save '${chosen}'"
2024-03-14 19:52:10 +00:00
2024-03-14 22:36:48 +00:00
# maybe change gtk theme?? and discord??
2024-02-23 21:12:18 +00:00
2024-03-14 19:52:10 +00:00
# recompile i3
i3-msg restart