hyprland-dotfiles/waybar/themeswitcher.sh

57 lines
2.3 KiB
Bash
Raw Normal View History

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