From 3f43e4e005ef160f0794467a77284ace3049d5af Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Wed, 2 Feb 2022 08:59:58 -0500 Subject: [PATCH] Support relative brightness increases/decreases --- home/bin/monitor-brightness | 10 ++++++++++ 1 file changed, 10 insertions(+) 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" -- 2.20.1