#!/usr/bin/env bash set -euo pipefail action="${1:-}" arg="${2:-}" polybar_scripts="/home/aag/.config/polybar/scripts" run_existing() { local script="$1" shift if [ -x "$polybar_scripts/$script" ]; then exec "$polybar_scripts/$script" "$@" fi } case "$action" in awake) run_existing awake-toggle.sh "$arg" ;; clipboard) run_existing clipboard-menu.sh ;; display) run_existing display-toggle.sh ;; display-brightness) run_existing display-brightness.sh "${arg:-up}" ;; dunst) command -v dunstctl >/dev/null 2>&1 || exit 0 case "$arg" in history) dunstctl history-pop ;; close) dunstctl close-all ;; *) dunstctl set-paused toggle ;; esac ;; keyboard) run_existing kb-switch.sh ;; mic) run_existing mic-toggle.sh ;; music) command -v playerctl >/dev/null 2>&1 || exit 0 case "$arg" in prev) playerctl previous ;; next) playerctl next ;; *) playerctl play-pause ;; esac ;; power) run_existing power-menu.sh ;; screenshot) run_existing screenshot-menu.sh ;; scratch) command -v i3-msg >/dev/null 2>&1 || exit 0 case "$arg" in move) i3-msg move scratchpad ;; *) i3-msg scratchpad show ;; esac ;; updates) run_existing updates-action.sh ;; volume) command -v pactl >/dev/null 2>&1 || { [ "$arg" = "" ] && command -v pavucontrol >/dev/null 2>&1 && exec pavucontrol exit 0 } case "$arg" in up) pactl set-sink-volume @DEFAULT_SINK@ +5% ;; down) pactl set-sink-volume @DEFAULT_SINK@ -5% ;; mute) pactl set-sink-mute @DEFAULT_SINK@ toggle ;; *) command -v pavucontrol >/dev/null 2>&1 && pavucontrol ;; esac ;; wg) run_existing wg-pc-toggle.sh "$arg" ;; esac