summaryrefslogtreecommitdiff
path: root/scripts/gui/sdev
blob: 2d80184eb79abbd7d3eb0f9228687cdb49f02346 (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
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

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

help() {
cat << EOF
${progname}: Disable and Enable devices
options:
 -e [dev]        Enable dev
 -d [dev]        Disable dev
 -t [dev]        Toggle dev
 -l              List devices
 -h              Print this message and exit

Note: Nondescriptive inputs may disable/enable unwanted devices.
EOF
exit 0
}

input_device_handle check_program

get_id() {
    id=$(input_device_handle get-id "$1") || exit 1
    printf '%s\n' "$id"
}

while getopts "e:d:t:lh" option; do
	case "${option}" in
	e) run "input_device_handle enable $(get_id ${OPTARG})" ;;
	d) run "input_device_handle disable $(get_id ${OPTARG})" ;;
	t)
		id=$(get_id ${OPTARG})
		if input_device_handle is_enabled "${id}"; then
			input_device_handle disable "${id}"
		else
			input_device_handle enable "${id}"
		fi
		exit $?
	;;
	l) run "input_device_handle list" ;;
	h) help ;;

	*) invalid_use -h ;;

	esac
done

invalid_use