Update volume module to work with pactl

This commit is contained in:
Baitinq 2021-12-07 23:13:55 +00:00 committed by GitHub
parent 36382a2604
commit d68a1e3372
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -6,11 +6,11 @@ VOLUME_ON_ICON=''
VOLUME_MUTED_ICON='' VOLUME_MUTED_ICON=''
get_volume(){ get_volume(){
active_sink=$(pacmd list-sinks | awk '/* index:/{print $3}') active_sink=$(pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | head -n 1)
curStatus=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | awk '/muted/{ print $2}') curStatus=$(pactl get-sink-mute $active_sink)
volume=$(pacmd list-sinks | grep -A 15 "index: $active_sink$" | grep 'volume:' | grep -E -v 'base volume:' | awk -F : '{print $3}' | grep -o -P '.{0,3}%'| sed s/.$// | tr -d ' ') volume=$(pactl get-sink-volume $active_sink | tail -n 2 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' | head -n 1)
if [ "${curStatus}" = 'yes' ] if [ "${curStatus}" = 'Mute: yes' ]
then then
echo "$VOLUME_MUTED_ICON $volume%" echo "$VOLUME_MUTED_ICON $volume%"
else else