generalize sslider over both PA and alsa

This commit is contained in:
Felix Van der Jeugt 2022-06-13 17:01:12 +02:00 committed by Felix Van der Jeugt
parent a2308c46ef
commit 1aee0d7eb4
No known key found for this signature in database
GPG Key ID: 58B209295023754D
1 changed files with 13 additions and 7 deletions

View File

@ -1,9 +1,15 @@
#!/bin/sh
control="$(amixer scontrols | sed -n "1s/.*'\(.*\)'.*/\1/p")"
if pamixer -v >/dev/null; then
uplimit=100
lolimit=0
current="$(pamixer --get-volume)"
setV() { pamixer --set-volume "$@"; }
else
control="$(amixer scontrols | sed -n "1s/.*'\(.*\)'.*/\1/p")"
uplimit="$(amixer get "$control" | grep "Limits:" | tr -s ' ' | cut -d' ' -f6)"
lolimit="$(amixer get "$control" | grep "Limits:" | tr -s ' ' | cut -d' ' -f4)"
current="$(amixer get "$control" | sed -n '/dB/{p;q}' | sed 's/.*Playback \([0-9]*\) .*/\1/')"
setV() { amixer -q set "$control" "$@"; }
fi
uplimit="$(amixer get "$control" | grep "Limits:" | tr -s ' ' | cut -d' ' -f6)"
lolimit="$(amixer get "$control" | grep "Limits:" | tr -s ' ' | cut -d' ' -f4)"
current="$(amixer get "$control" | sed -n '/dB/{p;q}' | sed 's/.*Playback \([0-9]*\) .*/\1/')"
wjt -l "$lolimit" -u "$uplimit" -x "$current" | while read next; do
amixer -q set "$control" "$next"
done
wjt -l "$lolimit" -u "$uplimit" -x "$current" | while read next; do setV "$next"; done