diff options
| author | Suleyman Farajli <suleyman@farajli.net> | 2025-11-25 18:47:27 +0400 |
|---|---|---|
| committer | Suleyman Farajli <suleyman@farajli.net> | 2025-11-25 18:47:27 +0400 |
| commit | d947956270b092df10637bb3531441caca698b86 (patch) | |
| tree | 8c32170ef044687b11be79398140a36430e2ff0a /scripts/gui/sdev | |
| parent | c388ade6b6d955138698731af02dfbe5c676439a (diff) | |
feat: new api for scripts
Diffstat (limited to 'scripts/gui/sdev')
| -rwxr-xr-x | scripts/gui/sdev | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/gui/sdev b/scripts/gui/sdev new file mode 100755 index 0000000..340bdb1 --- /dev/null +++ b/scripts/gui/sdev @@ -0,0 +1,49 @@ +#!/bin/sh + +. "lib_common.sh" +. "lib_handle.sh" + +help() { +cat << EOF +${0}: 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 |
