X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Fmonitor-brightness;h=07b7c4933b0000848a09f0872a94886541ca4e06;hb=101c2c385239d4de389357403085627e06fa7850;hp=9688ebe863b644eaccc5b5a8bfbd9e54d11678f3;hpb=880ba5be4bae1dcd5cedaece7843d7e7fc194d54;p=khome.git 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"