diff options
| author | jteijema <jelle@teije.ma> | 2025-07-23 13:44:50 +0200 |
|---|---|---|
| committer | jteijema <jelle@teije.ma> | 2025-07-23 13:44:50 +0200 |
| commit | 1ead947d065e8ca141a48743b7158ab2c1339336 (patch) | |
| tree | 590baa7eba1d65a78d97e17ea6b291c18d831e3e /config/hypr/scripts/WaybarLayout.sh | |
| parent | de427d033e48c3a847ecda680ada3a95f7961ed5 (diff) | |
feat: Add selected config highlighting for waybar
Diffstat (limited to 'config/hypr/scripts/WaybarLayout.sh')
| -rwxr-xr-x | config/hypr/scripts/WaybarLayout.sh | 50 |
1 files changed, 32 insertions, 18 deletions
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 ;; |
