Hyprland-dotfiles/waybar/themeswitcher.sh

57 lines
2.3 KiB
Bash
Raw Normal View History

2023-10-09 09:50:47 -04:00
#!/bin/bash
2023-10-10 10:54:41 -04:00
# _____ _ _ _ _
# |_ _| |__ ___ _ __ ___ ___ _____ _(_) |_ ___| |__ ___ _ __
# | | | '_ \ / _ \ '_ ` _ \ / _ \/ __\ \ /\ / / | __/ __| '_ \ / _ \ '__|
# | | | | | | __/ | | | | | __/\__ \\ V V /| | || (__| | | | __/ |
# |_| |_| |_|\___|_| |_| |_|\___||___/ \_/\_/ |_|\__\___|_| |_|\___|_|
#
# by Stephan Raabe (2023)
# -----------------------------------------------------
2023-10-18 10:15:52 -04:00
# -----------------------------------------------------
# Default theme folder
# -----------------------------------------------------
2023-10-10 10:54:41 -04:00
themes_path="$HOME/dotfiles/waybar/themes"
2023-10-18 10:15:52 -04:00
# -----------------------------------------------------
# Initialize arrays
# -----------------------------------------------------
2023-10-09 09:50:47 -04:00
listThemes=""
2023-10-10 10:54:41 -04:00
listNames=""
# -----------------------------------------------------
# Read theme folder
# -----------------------------------------------------
options=$(find $themes_path -maxdepth 2 -type d)
2023-10-09 09:50:47 -04:00
for value in $options
do
2023-10-10 10:54:41 -04:00
if [ ! $value == "$themes_path" ]; then
2023-10-09 09:50:47 -04:00
if [ $(find $value -maxdepth 1 -type d | wc -l) = 1 ]; then
2023-10-09 13:54:14 -04:00
result=$(echo $value | sed "s#$HOME/dotfiles/waybar/themes/#/#g")
2023-10-09 11:27:03 -04:00
IFS='/' read -ra arrThemes <<< "$result"
2023-10-10 10:54:41 -04:00
listThemes[${#listThemes[@]}]="/${arrThemes[1]};$result"
if [ -f $themes_path$result/config.sh ]; then
source $themes_path$result/config.sh
listNames+="$theme_name\n"
else
listNames+="/${arrThemes[1]};$result\n"
fi
2023-10-09 09:50:47 -04:00
fi
fi
done
2023-10-09 11:27:03 -04:00
2023-10-10 10:54:41 -04:00
# -----------------------------------------------------
# Show rofi dialog
# -----------------------------------------------------
listNames=${listNames::-2}
choice=$(echo -e "$listNames" | rofi -dmenu -config ~/dotfiles/rofi/config-wallpaper.rasi -no-show-icons -width 30 -p "Themes" -format i)
2023-10-09 11:27:03 -04:00
2023-10-10 10:54:41 -04:00
# -----------------------------------------------------
2023-10-18 10:15:52 -04:00
# Set new theme by writing the theme information to ~/.cache/.themestyle.sh
2023-10-10 10:54:41 -04:00
# -----------------------------------------------------
2023-10-09 11:27:03 -04:00
if [ "$choice" ]; then
2023-11-10 16:12:15 -05:00
echo "Loading waybar theme..."
2023-10-10 10:54:41 -04:00
echo "${listThemes[$choice+1]}" > ~/.cache/.themestyle.sh
2023-10-09 11:27:03 -04:00
~/dotfiles/waybar/launch.sh
2023-10-09 13:54:14 -04:00
fi