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/cli/slight | |
| parent | c388ade6b6d955138698731af02dfbe5c676439a (diff) | |
feat: new api for scripts
Diffstat (limited to 'scripts/cli/slight')
| -rwxr-xr-x | scripts/cli/slight | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/scripts/cli/slight b/scripts/cli/slight index 54edbcd..4efbf19 100755 --- a/scripts/cli/slight +++ b/scripts/cli/slight @@ -1,6 +1,7 @@ #!/bin/sh -. slib +. "lib_common.sh" +. "lib_handle.sh" help() { cat << EOF @@ -14,34 +15,22 @@ options: NOTE: Script interprets values as percentages EOF - exit 0 } -check_program "brightnessctl" - +brightness_handle check_program [ ${#} != 1 ] && [ ${#} != 2 ] && invalid_use while getopts "i:d:s:ph" option; do case "${option}" in - i) run --reload-status "brightnessctl set +${OPTARG}%" ;; - - d) run --reload-status "brightnessctl set ${OPTARG}-%" ;; - - s) run --reload-status "brightnessctl set ${OPTARG}%" ;; - - p) - if ! echo $(( ($(brightnessctl g) * 100) / $(brightnessctl m) )); then - err "Failed to get current brightness" - else - exit 0 - fi - ;; + i) run --reload-status "brightness_handle up ${OPTARG}" ;; + d) run --reload-status "brightness_handle down ${OPTARG}" ;; + s) run --reload-status "brightness_handle set ${OPTARG}" ;; + t) run --reload-status "brightness_handle toggle" ;; + p) brightness_handle get-current ;; h) help ;; *) invalid_use -h ;; - esac done - invalid_use |
