dotfiles/.local/bin/pavolctl

30 lines
619 B
Plaintext
Raw Normal View History

2022-05-27 21:07:07 +02:00
#!/bin/bash
SINK="@DEFAULT_SINK@"
LIMIT=150
ADJUSTMENT=$1
function limit_level() {
level="$(pactl get-sink-volume "$SINK" | grep '^Volume' | cut -d' ' -f5 | grep -o "[[:digit:]]*")"
if [[ "$level" -gt "$LIMIT" ]]; then
echo "Limiting volume to: $1"
set_level $LIMIT%
fi
}
function set_level() {
echo "Desired volume adjustment: $1"
pactl set-sink-volume "$SINK" "$1"
}
if [[ "$ADJUSTMENT" == set-*-mute ]]; then
echo "Desired volume adjustment: $1"
pactl "$ADJUSTMENT" "$SINK" toggle
else
set_level "$ADJUSTMENT"
limit_level $LIMIT
fi
killall -SIGUSR1 i3status