Improved volume block - added one for pipewire users
This commit is contained in:
parent
92cd084cfe
commit
b227e8bf42
44
blocks.def/volume.pipewire.sh
Executable file
44
blocks.def/volume.pipewire.sh
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# (for pipewire users)
|
||||||
|
# This script parses the output of `pacmd list-sinks' to find volume and mute
|
||||||
|
# status of the default audio sink and whether headphones are plugged in or not
|
||||||
|
# Also see ../daemons/pulse_daemon.sh
|
||||||
|
sink=$(pactl info | awk '$1 == "Default" && $2 == "Sink:" {print $3}')
|
||||||
|
[ -n "$sink" ] || exit
|
||||||
|
pactl list sinks | awk -v sink="$sink" '
|
||||||
|
BEGIN {
|
||||||
|
ICONsn = "\x0c\x0b" # headphone unplugged, not muted
|
||||||
|
ICONsm = "\x0d\x0b" # headphone unplugged, muted
|
||||||
|
ICONhn = "\x0c\x0b" # headphone plugged in, not muted
|
||||||
|
ICONhm = "\x0d\x0b" # headphone plugged in, muted
|
||||||
|
}
|
||||||
|
f {
|
||||||
|
if ($1 == "Mute:" && $2 == "yes") {
|
||||||
|
m = 1
|
||||||
|
} else if ($1 == "Volume:") {
|
||||||
|
if ($3 == $10) {
|
||||||
|
vb = $5
|
||||||
|
} else {
|
||||||
|
vl = $5
|
||||||
|
vr = $12
|
||||||
|
}
|
||||||
|
} else if ($1 == "Active" && $2 == "Port:") {
|
||||||
|
if (tolower($3) ~ /headphone/)
|
||||||
|
h = 1
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
next
|
||||||
|
}
|
||||||
|
$1 == "Name:" && $2 == sink {
|
||||||
|
f = 1
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if (f) {
|
||||||
|
printf "%s", h ? (m ? ICONhm : ICONhn) : (m ? ICONsm : ICONsn)
|
||||||
|
if (vb)
|
||||||
|
print vb
|
||||||
|
else
|
||||||
|
printf "L%s R%s\n", vl, vr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'
|
|
@ -1,20 +1,16 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# (for pulseaudio users)
|
||||||
# This script parses the output of `pacmd list-sinks' to find volume and mute
|
# This script parses the output of `pacmd list-sinks' to find volume and mute
|
||||||
# status of the default audio sink and whether headphones are plugged in or not
|
# status of the default audio sink and whether headphones are plugged in or not
|
||||||
# Also see ../daemons/pulse_daemon.sh
|
# Also see ../daemons/pulse_daemon.sh
|
||||||
pacmd list-sinks |
|
pacmd list-sinks | awk '
|
||||||
awk '
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
ICONsn = "\x0c\x0b" # headphone unplugged, not muted
|
ICONsn = "\x0c\x0b" # headphone unplugged, not muted
|
||||||
ICONsm = "\x0d\x0b" # headphone unplugged, muted
|
ICONsm = "\x0d\x0b" # headphone unplugged, muted
|
||||||
ICONhn = "\x0c\x0b" # headphone plugged in, not muted
|
ICONhn = "\x0c\x0b" # headphone plugged in, not muted
|
||||||
ICONhm = "\x0d\x0b" # headphone plugged in, muted
|
ICONhm = "\x0d\x0b" # headphone plugged in, muted
|
||||||
}
|
}
|
||||||
{
|
f {
|
||||||
if (f) {
|
|
||||||
if ($1 == "index:") {
|
|
||||||
exit
|
|
||||||
}
|
|
||||||
if ($1 == "muted:" && $2 == "yes") {
|
if ($1 == "muted:" && $2 == "yes") {
|
||||||
m = 1
|
m = 1
|
||||||
} else if ($1 == "volume:") {
|
} else if ($1 == "volume:") {
|
||||||
|
@ -24,21 +20,23 @@ pacmd list-sinks |
|
||||||
vl = $5
|
vl = $5
|
||||||
vr = $12
|
vr = $12
|
||||||
}
|
}
|
||||||
} else if ($1 == "active" && $2 == "port:" && $3 ~ /headphone/) {
|
} else if ($1 == "active" && $2 == "port:") {
|
||||||
|
if (tolower($3) ~ /headphone/)
|
||||||
h = 1
|
h = 1
|
||||||
|
exit
|
||||||
}
|
}
|
||||||
} else if ($1 == "*" && $2 == "index:") {
|
next
|
||||||
|
}
|
||||||
|
$1 == "*" && $2 == "index:" {
|
||||||
f = 1
|
f = 1
|
||||||
}
|
}
|
||||||
}
|
|
||||||
END {
|
END {
|
||||||
if (f) {
|
if (f) {
|
||||||
printf "%s", h ? (m ? ICONhm : ICONhn) : (m ? ICONsm : ICONsn)
|
printf "%s", h ? (m ? ICONhm : ICONhn) : (m ? ICONsm : ICONsn)
|
||||||
if (vb) {
|
if (vb)
|
||||||
print vb
|
print vb
|
||||||
} else {
|
else
|
||||||
printf "L%s R%s\n", vl, vr
|
printf "L%s R%s\n", vl, vr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
'
|
||||||
'
|
|
||||||
|
|
Loading…
Reference in a new issue