Improved volume block

This commit is contained in:
Ashish Kumar Yadav 2020-12-14 15:03:33 +05:30
parent 52535a44f5
commit 87611ea341

View file

@ -5,27 +5,36 @@ ICONsm=" " # headphone unplugged, muted
ICONsn=" " # headphone unplugged, not muted ICONsn=" " # headphone unplugged, not muted
pacmd list-sinks | pacmd list-sinks |
awk -v iconhm="$ICONhm" -v iconhn="$ICONhn" -v iconsm="$ICONsm" -v iconsn="$ICONsn" ' awk -v ihm="$ICONhm" -v ihn="$ICONhn" -v ism="$ICONsm" -v isn="$ICONsn" '
/\* index: /,0 { {
if ($1 == "index:") { if (f) {
exit if ($1 == "index:") {
} else if ($1 == "muted:" && $2 == "yes") { exit
muted = 1 }
} else if ($1 == "volume:") { if ($1 == "muted:" && $2 == "yes") {
volumel = $3 m = 1
volumer = $10 } else if ($1 == "volume:") {
volumelp = $5 if ($3 == $10) {
volumerp = $12 vb = $5
} else if ($1 == "active" && $2 == "port:" && $3 ~ /headphones/) { } else {
headphone = 1 vl = $5
vr = $12
}
} else if ($1 == "active" && $2 == "port:" && $3 ~ /headphone/) {
h = 1
}
} else if ($1 == "*" && $2 == "index:") {
f = 1
} }
} }
END { END {
printf "%s", headphone ? (muted ? iconhm : iconhn) : (muted ? iconsm : iconsn) if (f) {
if (volumel == volumer) { printf "%s", h ? (m ? ihm : ihn) : (m ? ism : isn)
print volumelp if (vb) {
} else { print vb
printf "L%s R%s\n", volumelp, volumerp } else {
printf "L%s R%s\n", vl, vr
}
} }
} }
' '