From 1ead947d065e8ca141a48743b7158ab2c1339336 Mon Sep 17 00:00:00 2001 From: jteijema Date: Wed, 23 Jul 2025 13:44:50 +0200 Subject: feat: Add selected config highlighting for waybar --- config/hypr/scripts/WaybarLayout.sh | 50 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'config/hypr/scripts/WaybarLayout.sh') diff --git a/config/hypr/scripts/WaybarLayout.sh b/config/hypr/scripts/WaybarLayout.sh index 0bea6ffe..88267cdb 100755 --- a/config/hypr/scripts/WaybarLayout.sh +++ b/config/hypr/scripts/WaybarLayout.sh @@ -9,17 +9,6 @@ waybar_layouts="$HOME/.config/waybar/configs" waybar_config="$HOME/.config/waybar/config" SCRIPTSDIR="$HOME/.config/hypr/scripts" rofi_config="$HOME/.config/rofi/config-waybar-layout.rasi" -msg=' 🎌 NOTE: Some waybar LAYOUT NOT fully compatible with some STYLES' - -# Function to display menu options -menu() { - options=() - while IFS= read -r file; do - options+=("$(basename "$file")") - done < <(find -L "$waybar_layouts" -maxdepth 1 -type f -exec basename {} \; | sort ) - - printf '%s\n' "${options[@]}" -} # Apply selected configuration apply_config() { @@ -27,16 +16,41 @@ apply_config() { "${SCRIPTSDIR}/Refresh.sh" & } -# Main function main() { - choice=$(menu | rofi -i -dmenu -config "$rofi_config" -mesg "$msg") + # Resolve current symlink target and basename + current_target=$(readlink -f "$waybar_config") + current_name=$(basename "$current_target") + + # Build sorted list of available layouts + mapfile -t options < <( + find -L "$waybar_layouts" -maxdepth 1 -type f -printf '%f\n' | sort + ) + + # Mark and locate the active layout + 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, pre‑selecting the active row + choice=$(printf '%s\n' "${options[@]}" \ + | rofi -i -dmenu \ + -config "$rofi_config" \ + -mesg "$msg" \ + -selected-row "$default_row" + ) + + # Exit if nothing chosen + [[ -z "$choice" ]] && { echo "No option selected. Exiting."; exit 0; } - if [[ -z "$choice" ]]; then - echo "No option selected. Exiting." - exit 0 - fi + # Strip marker before applying + choice=${choice% ⮕} - case $choice in + case "$choice" in "no panel") pgrep -x "waybar" && pkill waybar || true ;; -- cgit v1.2.3 From 11236530437df615d3bb3005d0c5ba386af084b9 Mon Sep 17 00:00:00 2001 From: Jelle Teijema Date: Wed, 23 Jul 2025 23:21:11 +0200 Subject: revert: removal of NOTE --- config/hypr/scripts/WaybarLayout.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'config/hypr/scripts/WaybarLayout.sh') diff --git a/config/hypr/scripts/WaybarLayout.sh b/config/hypr/scripts/WaybarLayout.sh index 88267cdb..3529a082 100755 --- a/config/hypr/scripts/WaybarLayout.sh +++ b/config/hypr/scripts/WaybarLayout.sh @@ -9,6 +9,7 @@ waybar_layouts="$HOME/.config/waybar/configs" waybar_config="$HOME/.config/waybar/config" SCRIPTSDIR="$HOME/.config/hypr/scripts" rofi_config="$HOME/.config/rofi/config-waybar-layout.rasi" +msg=' 🎌 NOTE: Some waybar LAYOUT NOT fully compatible with some STYLES' # Apply selected configuration apply_config() { -- cgit v1.2.3 From 43c7521efba41ce8430bc9a6825acc5a0147cbd3 Mon Sep 17 00:00:00 2001 From: "Ja.KooLit" <85185940+JaKooLit@users.noreply.github.com> Date: Fri, 25 Jul 2025 19:20:05 +0900 Subject: Update WaybarLayout.sh --- config/hypr/scripts/WaybarLayout.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'config/hypr/scripts/WaybarLayout.sh') diff --git a/config/hypr/scripts/WaybarLayout.sh b/config/hypr/scripts/WaybarLayout.sh index 3529a082..955432fc 100755 --- a/config/hypr/scripts/WaybarLayout.sh +++ b/config/hypr/scripts/WaybarLayout.sh @@ -31,7 +31,7 @@ main() { default_row=0 for i in "${!options[@]}"; do if [[ "${options[i]}" == "$current_name" ]]; then - options[i]="${options[i]} ⮕" + options[i]="👉 ${options[i]}" default_row=$i break fi -- cgit v1.2.3