summaryrefslogtreecommitdiff
path: root/.local/bin/vol
blob: 26cd77653d9397130cf58767f0dae49dccc49eef (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh
# vol - get/set volume of alsa control using amixer
# $1: control name (default is 'Master')
# $2: set the volume to value (optional)

amixer \
	$( [ -z "$2" ] && echo "get"	|| echo "set" ) \
	$( [ -z "$1" ] && echo "Master"	|| echo "$1" ) \
	"$2" \
	| sed -nE	-e '/\[on\]/	{ s/.*\[([0-9]+%)\].*/\1/;	p; q }' \
				-e '/\[off\]/	{ s/.*/MUTE/;				p; q }'