dotfiles/.config/hypr/scripts/theme-switcher.sh
2025-05-05 01:16:12 +02:00

88 lines
2 KiB
Bash
Executable file

#!/bin/bash
# borrowed from https://github.com/JaKooLit/wallpaper-switcher/
# WALLPAPERS PATH
DIR=$HOME/.config/hypr/themes
WAYBAR_CSS=$HOME/.config/waybar/style.css
LOOK_CONF=$HOME/.config/hypr/look.conf
DUNSTRC=$HOME/.config/dunst/dunstrc
KITTY_CONF=$HOME/.config/kitty/kitty.conf
WOFI_CSS=$HOME/.config/wofi/style.css
# Transition config (type swww img --help for more settings
FPS=30
TYPE="outer"
DURATION=3
# wofi window config (in %)
WIDTH=20
HEIGHT=40
THEMES=($(ls ${DIR}))
# WOFI STYLES
CONFIG=$HOME/.config/hypr/scripts/wofi_theme_switcher.conf
## Wofi Command
wofi_command="wofi --show dmenu \
--prompt choose...
--conf $CONFIG \
--width=$WIDTH% --height=$HEIGHT% \
--cache-file=/dev/null \
--hide-scroll --no-actions \
--matching=fuzzy"
menu(){
# Here we are looping in the PICS array that is composed of all images in the $DIR
# folder
for i in ${!THEMES[@]}; do
# get full path of the image
theme_name=${THEMES[$i]}
logo_path="${DIR}/${theme_name}/icon.png"
# keeping the .gif to make sue you know it is animated
printf "img:${logo_path}:text:${theme_name}\n"
done
}
main() {
choice=$(menu | ${wofi_command})
# no choice case
if [[ -z $choice ]]; then return; fi
theme_name=$(echo $choice | cut -d: -f4)
theme_path="${DIR}/${theme_name}"
waybar_path="${theme_path}/waybar.css"
conf_path="${theme_path}/look.conf"
dunstrc_path="${theme_path}/dunstrc"
kitty_path="${theme_path}/kitty.conf"
wofi_path="${theme_path}/wofi.css"
ln -sf $waybar_path $WAYBAR_CSS
ln -sf $conf_path $LOOK_CONF
ln -sf $dunstrc_path $DUNSTRC
ln -sf $kitty_path $KITTY_CONF
ln -sf $wofi_path $WOFI_CSS
# Reload waybar
pkill waybar
hyprctl dispatch exec waybar
# Reload dunst
pkill dunst
}
# Check if wofi is already running
if pidof wofi >/dev/null; then
killall wofi
exit 0
else
main
fi
# Uncomment to launch something if a choice was made
# if [[ -n "$choice" ]]; then
# Restart Waybar
# fi