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>
master
Clayton Craft 4 years ago committed by Stacy Harper
parent 4c3e6044ce
commit 921ab1773a
No known key found for this signature in database
GPG Key ID: 5BAC92328B7C5D65
  1. 4
      scripts/core/sxmo_brightness.sh

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

Loading…
Cancel
Save