summaryrefslogtreecommitdiff
path: root/scripts/cli/slight
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cli/slight')
-rwxr-xr-xscripts/cli/slight48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/cli/slight b/scripts/cli/slight
new file mode 100755
index 0000000..0289ff4
--- /dev/null
+++ b/scripts/cli/slight
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+. slib
+
+help() {
+cat << EOF
+${0}: Wrapper script to change backlight
+options:
+ -i [Brg] Increase backlight by Brg
+ -d [Brg] Decrease backlight by Brg
+ -s [Brg] Set backlight to Brg
+ -p Show the current backlight
+ -h Print this message and exit
+
+NOTE: Script interprets values as percentages
+EOF
+
+exit 0
+}
+
+check_program "brightnessctl"
+
+[ ${#} != 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
+ ;;
+ h) help ;;
+
+ *) invalid_use -h ;;
+
+ esac
+done
+
+# Unreachable
+invalid_use