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 (f) {
if ($1 == "index:") { if ($1 == "index:") {
exit exit
} else if ($1 == "muted:" && $2 == "yes") { }
muted = 1 if ($1 == "muted:" && $2 == "yes") {
m = 1
} else if ($1 == "volume:") { } else if ($1 == "volume:") {
volumel = $3 if ($3 == $10) {
volumer = $10 vb = $5
volumelp = $5 } else {
volumerp = $12 vl = $5
} else if ($1 == "active" && $2 == "port:" && $3 ~ /headphones/) { vr = $12
headphone = 1 }
} 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) {
print vb
} else { } else {
printf "L%s R%s\n", volumelp, volumerp printf "L%s R%s\n", vl, vr
}
} }
} }
' '