From: Siraaj Khandkar Date: Wed, 2 Feb 2022 13:59:58 +0000 (-0500) Subject: Support relative brightness increases/decreases X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=3f43e4e005ef160f0794467a77284ace3049d5af;p=khome.git Support relative brightness increases/decreases --- diff --git a/home/bin/monitor-brightness b/home/bin/monitor-brightness index 9688ebe..07b7c49 100755 --- a/home/bin/monitor-brightness +++ b/home/bin/monitor-brightness @@ -1,5 +1,13 @@ #! /bin/bash +max() { + if [[ "$1" -gt "$2" ]]; then echo "$1"; else echo "$2"; fi +} + +min() { + if [[ "$1" -lt "$2" ]]; then echo "$1"; else echo "$2"; fi +} + _get() { sudo ddcutil getvcp 10 | grep -o ' current value = \+[0-9]\+' | awk '{print $4}' } @@ -12,6 +20,8 @@ args="$*" case "$args" in '') _get;; + i | inc | increase) _set "$(min $(( $(_get) + 5)) 100)";; + d | dec | decrease) _set "$(max $(( $(_get) - 5)) 0)";; *) if [[ "$args" =~ ^[0-9]+$ && "$args" -gt -1 && "$args" -lt 101 ]]; then _set "$args"