rename themeswitcher.sh to switchtheme.sh

This commit is contained in:
Spangenberg
2023-10-25 22:20:38 +02:00
parent 692a072fad
commit f50bd38a76
4 changed files with 3 additions and 3 deletions

37
waybar/switchtheme.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Default theme folder
themes_path="$HOME/dotfiles/waybar/themes"
# Initialize arrays
listThemes=""
listNames=""
# Read theme folder
options=$(find $themes_path -maxdepth 2 -type d)
for value in $options
do
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]};${arrThemes[2]}"
if [ -f $themes_path/${arrThemes[1]}/${arrThemes[2]}/config.sh ]; then
source $themes_path/${arrThemes[1]}/${arrThemes[2]}/config.sh
listNames+="$theme_name\n"
else
listNames+="/${arrThemes[1]};$result\n"
fi
fi
fi
done
# 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)
# Set new theme by writing the theme information to ~/.cache/waybar.themestyle
if [ "$choice" ]; then
echo "${listThemes[$choice+1]}" > ~/.cache/waybar.themestyle
~/dotfiles/waybar/launch.sh
fi