Skip to content

Commit

Permalink
fix some mistakes
Browse files Browse the repository at this point in the history
Signed-off-by: Mattéo Rossillol‑‑Laruelle <[email protected]>
  • Loading branch information
beatussum committed Dec 27, 2019
1 parent 51f36f5 commit f816c0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PREFIX ?= /usr/local
DESTDIR ?=

INITDDIR ?= $(DESDIR)$(PREFIX)/etc/init.d
INITDDIR ?= $(DESTDIR)$(PREFIX)/etc/init.d

INSTALL ?= install -D -m755
RM ?= rm -f
Expand Down
19 changes: 13 additions & 6 deletions backlight-restorer
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@

description="An OpenRC service for restoring the last brightness level on reboot"

cache_dir="/var/cache/backlight-restorer"

start() {
ebegin "Restoring the screen brightness"

checkpath -D -o "root:root" "${cache_dir}"

for card in $(basename /sys/class/backlight/*); do
local -r blight=$(cat "/var/cache/backlight/${card}")
if [ ${blight} -ne 0 ]; then
if [ -e "${cache_dir}/${card}" ]; then
local -r blight=$(cat "${cache_dir}/${card}")
fi

if [ ${blight:=0} -ne 0 ]; then
echo ${blight} > "/sys/class/backlight/${card}/brightness"
fi

sts=$?
test ${sts} -ne 0 || break
test ${sts} -eq 0 || break
done

eend ${sts} "Cannot restore the brightness of ${card}"
Expand All @@ -37,14 +44,14 @@ start() {
stop() {
ebegin "Saving the screen brightness"

checkpath -D -o "root:root" /var/cache/backlight
checkpath -D -o "root:root" "${cache_dir}"

for card in $(basename /sys/class/backlight/*); do
cp "/sys/class/backlight/${card}/brightness" \
"/var/cache/backlight/${card}"
"${cache_dir}/${card}"

sts=$?
test ${sts} -ne 0 || break
test ${sts} -eq 0 || break
done

eend ${sts} "Cannot save the brightness of ${card}"
Expand Down

0 comments on commit f816c0c

Please sign in to comment.