summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2022-01-24 15:35:26 -0500
committerBrian Evans <grknight@gentoo.org>2022-01-24 15:35:26 -0500
commit9ea2c61a18715c5255266d67fbcdcf72e3c06c19 (patch)
treeea2f8a013598439086b194a63b637293205406fd /sys-power/acpilight/files
parentdev-python/pydot: workaround pyparsing-3 issue (diff)
downloadgentoo-9ea2c61a18715c5255266d67fbcdcf72e3c06c19.tar.gz
gentoo-9ea2c61a18715c5255266d67fbcdcf72e3c06c19.tar.bz2
gentoo-9ea2c61a18715c5255266d67fbcdcf72e3c06c19.zip
sys-power/acpilight: Add error handling to the OpenRC script
New script will not continue to save state when there is an error Closes: https://bugs.gentoo.org/831857 Signed-off-by: Brian Evans <grknight@gentoo.org>
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() {