sxmo_brightness.sh: write brightness val directly to sysfs

This removes the dependency on an external compiled app for writing the
brightness value to sysfs, and just echoes it directly to the backlight
sysfs node.

In addition, if the write fails, the script exits instead of sending a
misleading notification.

Signed-off-by: Stacy Harper <contact@stacyharper.net>
This commit is contained in:
Clayton Craft 2021-04-23 23:54:42 -07:00 committed by Stacy Harper
parent 4c3e6044ce
commit 921ab1773a
No known key found for this signature in database
GPG key ID: 5BAC92328B7C5D65

View file

@ -17,12 +17,14 @@ MINSTEP=1
STEP=$(echo "($MAX - $MIN) / 10" | bc | xargs -ISTP echo -e "$MINSTEP\nSTP" | sort -r | head -n1)
setdelta() {
sxmo_setpinebacklight "$(
VAL="$(
xargs -IB echo B "$1" < $BACKLIGHT/brightness |
bc |
xargs -INUM echo -e "$MIN\nNUM" | sort -n | tail -n1 |
xargs -INUM echo -e "$MAX\nNUM" | sort -n | head -n1
)"
echo "$VAL" > "$BACKLIGHT/brightness" || exit 1
echo "set brightness to $VAL"
dunstify -i 0 -u normal -r 999 "$(cat $BACKLIGHT/brightness)/${MAX}"
}