-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbacklight
More file actions
executable file
·36 lines (31 loc) · 845 Bytes
/
backlight
File metadata and controls
executable file
·36 lines (31 loc) · 845 Bytes
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
32
33
34
35
36
#!/sbin/openrc-run
cachedir="/var/cache/backlight";
cards="$(basename -a /sys/class/backlight/*)";
if [ ! -d $cachedir ]; then
mkdir -p $cachedir;
fi
for card in $cards; do
if [ ! -f $cachedir/$card ]; then
cat /sys/class/backlight/$card/brightness > $cachedir/$card;
fi
done
start() {
ebegin "Restoring screen brightness";
for card in $cards; do
local cache_value=$(cat $cachedir/$card);
if [ $cache_value -ne 0 ]; then
printf $cache_value > /sys/class/backlight/$card/brightness;
else
ewarn "Brightness should not zero, aborting ...";
return 3;
fi
done
return 0;
}
stop() {
ebegin "Saving screen brightness";
for card in $cards; do
cat /sys/class/backlight/$card/brightness > $cachedir/$card;
done
return 0;
}