X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=home%2Fbin%2Fmonitor-brightness;h=07b7c4933b0000848a09f0872a94886541ca4e06;hb=3f43e4e005ef160f0794467a77284ace3049d5af;hp=9688ebe863b644eaccc5b5a8bfbd9e54d11678f3;hpb=71ce30e23a8c3093aa9c488b8f3c528b0996678d;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"