Reputation: 337
I need to set the system volume in a bash script, but I have no idea how to do this.
Should I use alsactl
? Are there some values in /proc
or /sys
that I could use?
Upvotes: 3
Views: 5941
Reputation: 18
I've got a nice vol script in my ~/bin to help me do the trick ...
#!/bin/sh
export XDIALOG_NO_GMSGS=1
case ${1} in
+|-) VOL=( $(amixer set Master 10dB${1} |tail -1|tr -d "[]") )
Xdialog --no-buttons --title "Vol" --infobox ${VOL[3]} 50x30+32+32 ;;
*[0-9]) VOL=( $(amixer set Master "${1}%" |tail -1|tr -d "[]") )
Xdialog --no-buttons --title "Vol" --infobox ${VOL[3]} 50x30+32+32 ;;
*) printf "Usage: vol [+]|[-]|[0-100]\n" >&2 ;;
esac
If you don't have Xdialog installed a simple echo ${VOL[3]} will give you some alsamixer feedback.
Upvotes: 0
Reputation: 754
You can also use pactl
.
pactl set-sink-volume 0 60% # set absolute
pactl set-sink-volume 0 +10% # set relative
pactl set-sink-mute 0 0 # unmute
In particular, the pactl set-sink-mute 0 0
unmute command works on my computer where amixer set Master unmute
doesn't.
Upvotes: 2