.dotfiles/bin/set-vol
2023-04-04 18:37:56 +02:00

22 lines
495 B
Bash
Executable File

#!/bin/bash -e
SINK='@DEFAULT_AUDIO_SINK@'
if [ "$1" == 'm' ]; then
wpctl set-mute "$SINK" toggle
else
CUR="$((10#$(wpctl get-volume "$SINK" | tr -dc '0-9')))"
case "${1:0:1}" in
'') echo "$CUR"; exit ;;
'+'|'-') CUR="$((CUR - CUR % $1 + $1))" ;;
*) CUR="$1" ;;
esac
wpctl set-volume -l 1 "$SINK" "$CUR%"
wpctl set-mute "$SINK" 0
fi
# update sbar
kill -34 "$(cat "$HOME/.cache/pidofbar")"