summaryrefslogtreecommitdiff
path: root/scripts/cli/svol
blob: 64f4a2f006024c23996cca96f6cfdecf103f6513 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh

. "lib_common.sh"
. "lib_handle.sh"

help() {
cat << EOF
${progname}: Change volume
options:
 -i [Vol]        Increase volume by Vol
 -d [Vol]        Decrease volume by Vol
 -s [Vol]        Set volume to Vol
 -p              Show the current volume
 -t              Toggle between mute and unmute
 -h              Print this message and exit
EOF
exit 0
}

volume_handle check_program

[ $# != 1 ] && [ $# != 2 ] && invalid_use

while getopts "i:d:s:pth" option; do
	case "${option}" in
	i) run --reload-status "volume_handle up ${OPTARG}"   ;;
	d) run --reload-status "volume_handle down ${OPTARG}" ;;
	s) run --reload-status "volume_handle set ${OPTARG}"  ;;
	t) run --reload-status "volume_handle toggle"         ;;
	p) volume_handle get-current ;;
	h) help ;;

	*) invalid_use -h ;;
	esac
done
invalid_use