aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/WaybarStyles.sh
diff options
context:
space:
mode:
authorJa.KooLit <85185940+JaKooLit@users.noreply.github.com>2025-07-25 19:22:08 +0900
committerGitHub <noreply@github.com>2025-07-25 19:22:08 +0900
commitfc2d3f172f437082324aca858185bffbfd9e5c79 (patch)
treee8afcb5b15fb5fcc0f5f54fa931466003c0dbb4a /config/hypr/scripts/WaybarStyles.sh
parent1cf593996c75e0cbb563648538ab6e3b3b85355d (diff)
parent637025eeb60391e5cc17c883aa6ee95799acac76 (diff)
Merge pull request #773 from JaKooLit/main
Main to development
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