dotfiles/.local/bin/vol
2025-06-29 09:30:03 +00:00

26 lines
548 B
Bash
Executable File

#!/bin/bash -e
case "$1" in
s) DEV='@DEFAULT_AUDIO_SINK@' ;;
m) DEV='@DEFAULT_AUDIO_SOURCE@' ;;
*) exit 1 ;;
esac
read -r _ CUR MUTE < <(wpctl get-volume "$DEV")
CUR=$((10#${CUR/./}))
if [ "$2" = m ]; then
wpctl set-mute "$DEV" toggle
else
case "$2" in
+*|-*) wpctl set-volume -l 1.5 "$DEV" "$((CUR + $2))%" ;;
'') echo "$CUR${MUTE:+ $MUTE}"; exit ;;
*) wpctl set-volume "$DEV" "$2%" ;;
esac
if [ -n "$MUTE" ]; then
wpctl set-mute "$DEV" 0
fi
fi
touch "$XDG_RUNTIME_DIR/sbar/vol"