dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

commit 86132a1819e64a16086bbec1e31bf1e800241d80
parent c70e8e6d8c65786d4c25675868ed6f49d0f02922
Author: Matthew Carlson <matt@mcarlson.xyz>
Date:   Mon, 23 Aug 2021 23:55:43 -0400

fixed monitor brightness arithmetic going out of bounds

Diffstat:
M.local/bin/bar/monitor.sh | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/.local/bin/bar/monitor.sh b/.local/bin/bar/monitor.sh @@ -20,11 +20,15 @@ set_brightness() { # keep between 0-100 if [ "${1}" = '+' ]; then - if [ "${brightness}" -lt 100 ]; then brightness=$((brightness + ${2})) + if [ "${brightness}" -lt 100 ]; then + brightness=$((brightness + ${2})) + [ "${brightness}" -gt 100 ] && brightness=100 else return fi elif [ "${1}" = '-' ]; then - if [ "${brightness}" -gt 0 ]; then brightness=$((brightness - ${2})) + if [ "${brightness}" -gt 0 ]; then + brightness=$((brightness - ${2})) + [ "${brightness}" -lt 0 ] && brightness=0 else return fi fi