Changes the volume script to work with pulseaudio-ctl
https://github.com/graysky2/pulseaudio-ctl using amixer is a pain and this takes a lot of the complexity out of it. If pulseaudio-ctl isn't available, the script will still use amixer
This commit is contained in:
parent
f08de9faf5
commit
0af5b4e4df
1 changed files with 22 additions and 5 deletions
|
@ -24,17 +24,34 @@ function drawBar(){
|
|||
|
||||
case "$1" in
|
||||
"up")
|
||||
if type -p pulseaudio-ctl 2> /dev/null; then
|
||||
pulseaudio-ctl up
|
||||
else
|
||||
amixer -q -D default sset Master 5%+ unmute
|
||||
fi
|
||||
;;
|
||||
"down")
|
||||
if type -p pulseaudio-ctl 2> /dev/null; then
|
||||
pulseaudio-ctl down
|
||||
else
|
||||
amixer -q -D default sset Master 5%- unmute
|
||||
fi
|
||||
;;
|
||||
"toggle")
|
||||
if type -p pulseaudio-ctl 2> /dev/null; then
|
||||
pulseaudio-ctl mute
|
||||
else
|
||||
amixer -q -D default sset Master toggle
|
||||
fi
|
||||
esac
|
||||
|
||||
volume="$(amixer -D default sget Master | grep -o '\[.*\%' | head -n 1 | tr -d '[%')"
|
||||
speakerStatus="$(amixer -D default sget Master | grep -o '\[\(on\|off\)' | head -n 1 | tr -d '[')"
|
||||
if type -p pulseaudio-ctl 2> /dev/null; then
|
||||
volume="$(pulseaudio-ctl full-status | cut -d ' ' -f1)"
|
||||
speakerStatus="$(pulseaudio-ctl full-status | cut -d ' ' -f2 | sed 's/no/on/g')"
|
||||
else
|
||||
volume="$(amixer -D default sget Master | grep -o '\[.*\%' | head -n 1 | tr -d '[%')"
|
||||
speakerStatus="$(amixer -D default sget Master | grep -o '\[\(on\|off\)' | head -n 1 | tr -d '[')"
|
||||
fi
|
||||
|
||||
|
||||
if [[ "$speakerStatus" == "on" ]]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue