aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/WaybarStyles.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/hypr/scripts/WaybarStyles.sh')
-rwxr-xr-xconfig/hypr/scripts/WaybarStyles.sh49
1 files changed, 31 insertions, 18 deletions
diff --git a/config/hypr/scripts/WaybarStyles.sh b/config/hypr/scripts/WaybarStyles.sh
index 246a66a2..20f0873b 100755
--- a/config/hypr/scripts/WaybarStyles.sh
+++ b/config/hypr/scripts/WaybarStyles.sh
@@ -11,33 +11,46 @@ SCRIPTSDIR="$HOME/.config/hypr/scripts"
rofi_config="$HOME/.config/rofi/config-waybar-style.rasi"
msg=' 🎌 NOTE: Some waybar STYLES NOT fully compatible with some LAYOUTS'
-# Function to display menu options
-menu() {
- options=()
- while IFS= read -r file; do
- if [ -f "$waybar_styles/$file" ]; then
- options+=("$(basename "$file" .css)")
- fi
- done < <(find -L "$waybar_styles" -maxdepth 1 -type f -name '*.css' -exec basename {} \; | sort )
-
- printf '%s\n' "${options[@]}"
-}
-
# Apply selected style
apply_style() {
ln -sf "$waybar_styles/$1.css" "$waybar_style"
"${SCRIPTSDIR}/Refresh.sh" &
}
-# Main function
main() {
- choice=$(menu | rofi -i -dmenu -config "$rofi_config" -mesg "$msg")
+ # resolve current symlink and strip .css
+ current_target=$(readlink -f "$waybar_style")
+ current_name=$(basename "$current_target" .css)
+
+ # gather all style names (without .css) into an array
+ mapfile -t options < <(
+ find -L "$waybar_styles" -maxdepth 1 -type f -name '*.css' \
+ -exec basename {} .css \; \
+ | sort
+ )
+
+ # mark the active style and record its index
+ default_row=0
+ for i in "${!options[@]}"; do
+ if [[ "${options[i]}" == "$current_name" ]]; then
+ options[i]="👉 ${options[i]}"
+ default_row=$i
+ break
+ fi
+ done
+
+ # launch rofi with the annotated list and pre‑selected row
+ choice=$(printf '%s\n' "${options[@]}" \
+ | rofi -i -dmenu \
+ -config "$rofi_config" \
+ -mesg "$msg" \
+ -selected-row "$default_row"
+ )
- if [[ -z "$choice" ]]; then
- echo "No option selected. Exiting."
- exit 0
- fi
+ [[ -z "$choice" ]] && { echo "No option selected. Exiting."; exit 0; }
+ # remove annotation and apply
+ choice=${choice% ⮕}
apply_style "$choice"
}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage