hyprland-dotfiles/waybar/themeswitcher.sh

59 lines
2.4 KiB
Bash
Raw Permalink Normal View History

2023-10-09 13:50:47 +00:00
#!/bin/bash
2023-10-10 14:54:41 +00:00
# _____ _ _ _ _
# |_ _| |__ ___ _ __ ___ ___ _____ _(_) |_ ___| |__ ___ _ __
# | | | '_ \ / _ \ '_ ` _ \ / _ \/ __\ \ /\ / / | __/ __| '_ \ / _ \ '__|
# | | | | | | __/ | | | | | __/\__ \\ V V /| | || (__| | | | __/ |
# |_| |_| |_|\___|_| |_| |_|\___||___/ \_/\_/ |_|\__\___|_| |_|\___|_|
#
2024-02-21 07:42:16 +00:00
# by Stephan Raabe (2024)
2023-10-10 14:54:41 +00:00
# -----------------------------------------------------
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
2024-02-21 07:42:16 +00:00
if [ ! $value == "$HOME/dotfiles/waybar/themes/assets" ]; then
if [ ! $value == "$themes_path" ]; then
if [ $(find $value -maxdepth 1 -type d | wc -l) = 1 ]; then
result=$(echo $value | sed "s#$HOME/dotfiles/waybar/themes/#/#g")
IFS='/' read -ra arrThemes <<< "$result"
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-10 14:54:41 +00:00
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