forked from antipatico/backlight-openrc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbacklight
executable file
·31 lines (26 loc) · 939 Bytes
/
backlight
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/sbin/openrc-run
# created by [email protected], with patch from Raphael Costa Raphael
# with this software you have no kind of support.
#
start() {
ebegin 'Restoring the screen brightness'
for card in "$(find /sys/class/backlight/ -type l)"; do
if [ -r "/var/cache/backlight/$(basename $card)-brightness-old" ]; then
cp "/var/cache/backlight/$(basename $card)-brightness-old" "/sys/class/backlight/$(basename $card)/brightness"
fi
done
eend $?
}
stop() {
ebegin 'Saving the screen brightness'
if ! [ -d '/var/cache/backlight/' ]; then
mkdir '/var/cache/backlight'
fi
if ! [ -w '/var/cache/backlight/' ]; then
chmod 755 '/var/cache/backlight/'
fi
for card in "$(find /sys/class/backlight/ -type l)"; do
cp "/sys/class/backlight/$(basename $card)/brightness" "/var/cache/backlight/$(basename $card)-brightness-old"
done
eend $?
}