dotfiles/bin/set-vol

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 -35 "$(cat "$HOME/.cache/pidofbar")"