arch-waybar/scripts/switch-layout.sh
Nicholai 600a35020b Fix symlink paths to use absolute paths
Changed scripts to use realpath() to create absolute symlinks
instead of relative paths, which were breaking with filenames
containing special characters. Also added sleep delay before
restarting waybar.
2025-11-23 23:13:58 -07:00

33 lines
916 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
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