Unverified Commit 9d27a43b authored by Mark Vander Stel's avatar Mark Vander Stel
Browse files

Fix picking acpi battery backend when invalid

With the removal of the command -v check, anything returned on stdout
would make acpi be a valid backend. This can happen in the
command_not_found_handle() function is defined.

Also don't pick a backend if the data function returns an error code.

Further strictness could be to check that the string returned is a valid
int, but that is probably overkill.

Fixes #690
parent c5d630d5
......@@ -2391,13 +2391,15 @@ case "$LP_OS" in
# First check SYSFS way.
_LP_BATTERY_FUNCTION=__lp_battery_sysfs
"$_LP_BATTERY_FUNCTION" 2>/dev/null
[[ -n "${lp_battery-}" ]] && return 0
"$_LP_BATTERY_FUNCTION" 2>/dev/null && \
[[ -n "${lp_battery-}" ]] && return 0
# Try with ACPI.
_LP_BATTERY_FUNCTION=__lp_battery_acpi
"$_LP_BATTERY_FUNCTION" 2>/dev/null
[[ -n "${lp_battery-}" ]] && return 0
if command -v apci >/dev/null; then
_LP_BATTERY_FUNCTION=__lp_battery_acpi
"$_LP_BATTERY_FUNCTION" 2>/dev/null && \
[[ -n "${lp_battery-}" ]] && return 0
fi
unset _LP_BATTERY_FUNCTION
return 1
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment