From d947956270b092df10637bb3531441caca698b86 Mon Sep 17 00:00:00 2001 From: Suleyman Farajli Date: Tue, 25 Nov 2025 18:47:27 +0400 Subject: feat: new api for scripts --- scripts/cli/slight | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'scripts/cli/slight') 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 -- cgit v1.2.3