#!/usr/bin/env bash set -euo pipefail requested="${1:-toggle}" state_dir="${XDG_RUNTIME_DIR:-/tmp}" if [ ! -w "$state_dir" ]; then state_dir="${XDG_CACHE_HOME:-$HOME/.cache}" mkdir -p "$state_dir" 2>/dev/null || true fi if [ ! -w "$state_dir" ]; then state_dir="/tmp" fi mode_file="$state_dir/polybar-mode.state" current="compact" if [ -r "$mode_file" ]; then current="$(cat "$mode_file")" fi case "$requested" in full|expand|expanded) next="full" ;; compact|minimize|minimized) next="compact" ;; toggle) if [ "$current" = "full" ]; then next="compact" else next="full" fi ;; *) exit 2 ;; esac printf '%s\n' "$next" >"$mode_file" if command -v dunstify >/dev/null 2>&1; then dunstify -a polybar -u low "Polybar" "$next mode" fi /home/aag/.config/polybar/launch.sh >/tmp/polybar-mode-toggle.log 2>&1 &