From e30643d4bb16ef45faa5e34bacd01258c273ab18 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Tue, 10 Oct 2023 16:54:41 +0200 Subject: [PATCH] Add config files to waybar themes --- waybar/themes/default/config.sh | 2 ++ waybar/themes/ml4w-bottom/dark/config.sh | 2 ++ waybar/themes/ml4w-bottom/light/config.sh | 2 ++ waybar/themes/ml4w-bottom/mixed/config.sh | 2 ++ waybar/themes/ml4w/dark/config.sh | 2 ++ waybar/themes/ml4w/light/config.sh | 2 ++ waybar/themes/ml4w/mixed/config.sh | 2 ++ waybar/themeswitcher.sh | 40 +++++++++++++++++++---- 8 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 waybar/themes/default/config.sh create mode 100644 waybar/themes/ml4w-bottom/dark/config.sh create mode 100644 waybar/themes/ml4w-bottom/light/config.sh create mode 100644 waybar/themes/ml4w-bottom/mixed/config.sh create mode 100644 waybar/themes/ml4w/dark/config.sh create mode 100644 waybar/themes/ml4w/light/config.sh create mode 100644 waybar/themes/ml4w/mixed/config.sh diff --git a/waybar/themes/default/config.sh b/waybar/themes/default/config.sh new file mode 100644 index 0000000..e7b45d3 --- /dev/null +++ b/waybar/themes/default/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="Default" \ No newline at end of file diff --git a/waybar/themes/ml4w-bottom/dark/config.sh b/waybar/themes/ml4w-bottom/dark/config.sh new file mode 100644 index 0000000..a6fe8ff --- /dev/null +++ b/waybar/themes/ml4w-bottom/dark/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Dark Bottom" \ No newline at end of file diff --git a/waybar/themes/ml4w-bottom/light/config.sh b/waybar/themes/ml4w-bottom/light/config.sh new file mode 100644 index 0000000..e016502 --- /dev/null +++ b/waybar/themes/ml4w-bottom/light/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Light Bottom" \ No newline at end of file diff --git a/waybar/themes/ml4w-bottom/mixed/config.sh b/waybar/themes/ml4w-bottom/mixed/config.sh new file mode 100644 index 0000000..e5bc67e --- /dev/null +++ b/waybar/themes/ml4w-bottom/mixed/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Mixed Bottom" \ No newline at end of file diff --git a/waybar/themes/ml4w/dark/config.sh b/waybar/themes/ml4w/dark/config.sh new file mode 100644 index 0000000..6c2cf9f --- /dev/null +++ b/waybar/themes/ml4w/dark/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Dark" \ No newline at end of file diff --git a/waybar/themes/ml4w/light/config.sh b/waybar/themes/ml4w/light/config.sh new file mode 100644 index 0000000..13fe9df --- /dev/null +++ b/waybar/themes/ml4w/light/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Light" \ No newline at end of file diff --git a/waybar/themes/ml4w/mixed/config.sh b/waybar/themes/ml4w/mixed/config.sh new file mode 100644 index 0000000..c00e231 --- /dev/null +++ b/waybar/themes/ml4w/mixed/config.sh @@ -0,0 +1,2 @@ +#!/bin/bash +theme_name="ML4W Mixed" \ No newline at end of file diff --git a/waybar/themeswitcher.sh b/waybar/themeswitcher.sh index cb3942d..9bfb190 100755 --- a/waybar/themeswitcher.sh +++ b/waybar/themeswitcher.sh @@ -1,22 +1,48 @@ #!/bin/bash -options=$(find ~/dotfiles/waybar/themes/ -maxdepth 2 -type d) +# _____ _ _ _ _ +# |_ _| |__ ___ _ __ ___ ___ _____ _(_) |_ ___| |__ ___ _ __ +# | | | '_ \ / _ \ '_ ` _ \ / _ \/ __\ \ /\ / / | __/ __| '_ \ / _ \ '__| +# | | | | | | __/ | | | | | __/\__ \\ V V /| | || (__| | | | __/ | +# |_| |_| |_|\___|_| |_| |_|\___||___/ \_/\_/ |_|\__\___|_| |_|\___|_| +# +# by Stephan Raabe (2023) +# ----------------------------------------------------- + +themes_path="$HOME/dotfiles/waybar/themes" listThemes="" +listNames="" + +# ----------------------------------------------------- +# Read theme folder +# ----------------------------------------------------- +options=$(find $themes_path -maxdepth 2 -type d) for value in $options do - if [ ! $value == "$HOME/dotfiles/waybar/themes/" ]; 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" - echo $arrThemes - listThemes+="/${arrThemes[1]};$result\n" + 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 fi fi done -listThemes=${listThemes::-2} +# ----------------------------------------------------- +# 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) -choice=$(echo -e "$listThemes" | rofi -dmenu -config ~/dotfiles/rofi/config-wallpaper.rasi -no-show-icons -width 30 -p "Themes") +# ----------------------------------------------------- +# Set new theme by writing the theme information to ~/.cache +# ----------------------------------------------------- if [ "$choice" ]; then - echo "$choice" > ~/.cache/.themestyle.sh + echo "${listThemes[$choice+1]}" > ~/.cache/.themestyle.sh ~/dotfiles/waybar/launch.sh fi