mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-03-24 06:51:37 +01:00
The application brightnessctl can control two different classes of sysfs devices, "backlight" and "leds". When it searches for devices it first goes thtrough the "backlight" class and thereafter through the "leds" class. If no class or device is specified by the command line, it acts on the first device it has found. Using the openrc service script on boot works fine if there is a backlight available. However, if there is no backlight, brightnessctl starts to mess around with the first LED it finds, causing potentially strange things. Therefore exit the openrc service if there is no backlight.
28 lines
658 B
Bash
28 lines
658 B
Bash
#!/sbin/openrc-run
|
|
|
|
description="Save and restore display backlight settings"
|
|
|
|
save_file="/var/lib/brightnessctl/state"
|
|
|
|
start() {
|
|
ebegin "Setting brightness to saved value"
|
|
# fails to start first time if file does not exist
|
|
if [ -f "$save_file" ]; then
|
|
brightnessctl --class=backlight --quiet set "$(cat "$save_file")" 2>/dev/null
|
|
if [ $? -ne 0 ]; then
|
|
einfo "Skipping, no backlight device available"
|
|
return 0
|
|
fi
|
|
fi
|
|
eend $?
|
|
}
|
|
stop() {
|
|
ebegin "Saving brightness value"
|
|
brightnessctl --class=backlight --quiet get 2>/dev/null > "$save_file"
|
|
if [ $? -ne 0 ]; then
|
|
einfo "Skipping, no backlight device available"
|
|
return 0
|
|
fi
|
|
eend $?
|
|
}
|