59 lines
1.3 KiB
Plaintext
59 lines
1.3 KiB
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
status() {
|
||
|
MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}')
|
||
|
|
||
|
if [ "$MUTED" = "yes" ]; then
|
||
|
echo -e "%{T4}%{F#FF0008}%{B#353B45} %{T2}muted"
|
||
|
else
|
||
|
echo -e "%{T4}%{F#80E6FE}%{B#353B45} %{T2}$(pacmd list-sources | grep "\* index:" -A 7 | grep volume | awk -F/ '{print $2}' | tr -d ' ')"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
|
||
|
listen() {
|
||
|
status
|
||
|
LANG=EN; pactl subscribe | while read -r event;
|
||
|
do
|
||
|
if echo -e "$event" | grep -q "source" || echo "$event" | grep -q "server"; then
|
||
|
status
|
||
|
fi
|
||
|
done
|
||
|
}
|
||
|
|
||
|
toggle() {
|
||
|
MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}')
|
||
|
DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
|
||
|
|
||
|
if [ "$MUTED" = "yes" ]; then
|
||
|
pactl set-source-mute "$DEFAULT_SOURCE" 0
|
||
|
else
|
||
|
pactl set-source-mute "$DEFAULT_SOURCE" 1
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
increase() {
|
||
|
DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
|
||
|
pactl set-source-volume "$DEFAULT_SOURCE" +5%
|
||
|
}
|
||
|
|
||
|
decrease() {
|
||
|
DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
|
||
|
pactl set-source-volume "$DEFAULT_SOURCE" -5%
|
||
|
}
|
||
|
|
||
|
case "$1" in
|
||
|
--toggle)
|
||
|
toggle
|
||
|
;;
|
||
|
--increase)
|
||
|
increase
|
||
|
;;
|
||
|
--decrease)
|
||
|
decrease
|
||
|
;;
|
||
|
*)
|
||
|
listen
|
||
|
;;
|
||
|
esac
|