summaryrefslogtreecommitdiff
path: root/sys-power/acpilight/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@koprulu.sector>2022-02-02 01:39:05 +0000
committerV3n3RiX <venerix@koprulu.sector>2022-02-02 01:39:05 +0000
commitfcc5224904648a8e6eb528d7603154160a20022f (patch)
tree3bfce096b38a9cea8eed13fc70c1526c456e9abd /sys-power/acpilight/files
parent2fd57282f0262ca084e05b0f2c63fbada395d02b (diff)
gentoo resync : 02.02.2022
Diffstat (limited to 'sys-power/acpilight/files')
-rw-r--r--sys-power/acpilight/files/acpilight.initd17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys-power/acpilight/files/acpilight.initd b/sys-power/acpilight/files/acpilight.initd
index 0de6029867e0..780828246712 100644
--- a/sys-power/acpilight/files/acpilight.initd
+++ b/sys-power/acpilight/files/acpilight.initd
@@ -1,5 +1,5 @@
#!/sbin/openrc-run
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
state_dir=/var/lib/acpilight
@@ -19,13 +19,22 @@ restore() {
return 0
fi
xbacklight "$(cat "${state_dir}/state")"
- eend $?
+ ewend $? "Could not restore brightness. The state file ${state_dir}/state is invalid or the system cannot apply the value."
}
save() {
+ local newValue
ebegin "Saving brightness level"
- mkdir -p "${state_dir}" && xbacklight -get > "${state_dir}/state"
- eend $?
+ # Save the value here so an error won't record an empty/invalid value
+ newValue=$(xbacklight -get) && \
+ mkdir -p "${state_dir}" && \
+ echo "${newValue}" > "${state_dir}/state"
+ if [ $? -gt 0 ]; then
+ ewarn "Could not save brightness."
+ ewarn "The state file ${state_dir}/state cannot be written to or the system cannot read the brightness value."
+ fi
+ # Don't fail on error
+ eend 0
}
start() {