arch-waybar/scripts/switch-layout.sh
Nicholai 2fa5c52963 Fix critical bug in switcher scripts array building
Fixed broken array building that was splitting filenames with spaces/brackets:
- Changed from: layouts=$(($command)) which splits on whitespace
- Changed to: mapfile -t which preserves full filenames

This fixes:
- Wofi showing 69 broken fragments instead of 25 layouts
- Wofi showing 83 broken fragments instead of 30 styles
- Symlinks pointing to non-existent fragmented paths
- Layouts not actually changing when selected

Also repaired broken config symlink that pointed to non-existent
/home/nicholai/.config/waybar/configs/BOT] back to working
Custom Minimal layout.
2025-11-24 04:18:45 -07:00

33 lines
977 B
Bash
Executable File

#!/bin/bash
# Quick waybar layout switcher
waybar_layouts="$HOME/.config/waybar/configs"
waybar_config="$HOME/.config/waybar/config"
# Get all available layouts (using mapfile to preserve filenames with spaces)
mapfile -t layouts < <(ls "$waybar_layouts" | sort)
# If wofi is available, use it for selection
if command -v wofi &> /dev/null; then
choice=$(printf '%s\n' "${layouts[@]}" | wofi --dmenu -i -p "Waybar Layout" --parse-search false)
else
# Otherwise use a simple CLI menu
echo "Available Waybar Layouts:"
for i in "${!layouts[@]}"; do
echo "$((i+1)). ${layouts[$i]}"
done
read -p "Select layout (1-${#layouts[@]}): " selection
choice="${layouts[$((selection-1))]}"
fi
if [[ -n "$choice" ]]; then
# Use absolute path for the symlink target
ln -sf "$(realpath "$waybar_layouts/$choice")" "$waybar_config"
echo "Switched to: $choice"
killall waybar
sleep 0.5
waybar &
else
echo "No selection made"
fi