Switch from light to brightnessctl

light has been flagged as orphan by its developper, and dropped from
aports.

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/49859
https://github.com/haikarainen/light/issues/147

We switch to brightnessctl that works the same, and that also support
flashlight and leds.
This commit is contained in:
Willow Barraco
2023-08-11 08:49:37 +02:00
parent 4a6b4f6981
commit d0384a7cae

View File

@@ -10,27 +10,36 @@
notify() { notify() {
if [ "$SXMO_WM" = "sway" ] && [ -z "$SXMO_WOB_DISABLE" ]; then if [ "$SXMO_WM" = "sway" ] && [ -z "$SXMO_WOB_DISABLE" ]; then
light | grep -o "^[0-9]*" > "$XDG_RUNTIME_DIR"/sxmo.wobsock getvalue > "$XDG_RUNTIME_DIR"/sxmo.wobsock
else else
light | xargs dunstify -r 888 "$icon_brightness Brightness" getvalue | xargs dunstify -r 888 "$icon_brightness Brightness"
fi fi
} }
setvalue() { setvalue() {
light -S "$1" brightnessctl set "$1"%
} }
up() { up() {
light -A 5 brightnessctl set 5%+
} }
down() { down() {
light -N "${SXMO_MIN_BRIGHTNESS:-5}" # bugged https://github.com/Hummer12007/brightnessctl/issues/82
light -U 5 # brightnessctl --min-value "${SXMO_MIN_BRIGHTNESS:-5}" set 5%-
if [ "$(getvalue)" -gt "${SXMO_MIN_BRIGHTNESS:-5}" ]; then
brightnessctl set 5%-
else
brightnessctl set "${SXMO_MIN_BRIGHTNESS:-5}"%
fi
} }
getvalue() { getvalue() {
light brightnessctl info \
| grep "Current brightness:" \
| awk '{ print $NF }' \
| grep -o "[0-9]*"
} }
"$@" "$@"