[Pkg-wmaker-commits] [wmbattery] 33/241: * Work around stupid ACPI output format bug. Critical battery detection now works.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmbattery.
commit c61aa9de4fddd4750d1e66802ac95eb175e08083
Author: joey <joey at a4a2c43b-8ac3-0310-8836-e0e880c912e2>
Date: Tue Apr 9 02:55:29 2002 +0000
* Work around stupid ACPI output format bug. Critical battery detection
now works.
---
acpi.c | 29 +++++++++++++----------------
debian/changelog | 13 +++++++++++++
wmbattery.c | 2 +-
3 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/acpi.c b/acpi.c
index 8770594..8248ea7 100644
--- a/acpi.c
+++ b/acpi.c
@@ -167,13 +167,11 @@ int acpi_supported (void) {
char *version;
if (chdir("/proc/acpi") == -1) {
- perror("chdir /proc/acpi");
return 0;
}
version = get_acpi_value("info", "ACPI-CA Version:");
if (version == NULL) {
- fprintf(stderr, "Unable to find ACPI version.\n");
return 0;
}
if (atoi(version) < ACPI_VERSION) {
@@ -181,20 +179,11 @@ int acpi_supported (void) {
version, ACPI_VERSION);
return 0;
}
-
- if (! find_batteries()) {
- fprintf(stderr, "No ACPI batteries found!");
- return 0;
- }
-
- if (! find_ac_adapters()) {
- fprintf(stderr, "No ACPI power adapter found!");
- }
-
+
+ find_batteries();
+ find_ac_adapters();
#if ACPI_THERMAL
- if (! find_thermal()) {
- fprintf(stderr, "No ACPI thermal information found.");
- }
+ find_thermal();
#endif
return 1;
@@ -245,6 +234,13 @@ int acpi_read (int battery, apm_info *info) {
if (state) {
if (state[0] == 'd') { /* discharging */
info->battery_status = BATTERY_STATUS_CHARGING;
+ /* In a serious fit of stupidity, Linux's
+ * ACPI output uses a *second* State: line
+ * when the battery is critically low.
+ * Detect that. */
+ if (state && state[0] == 'c') { /* critical */
+ info->battery_status = BATTERY_STATUS_CRITICAL;
+ }
}
else if (state[0] == 'c' && state[1] == 'h') { /* charging */
info->battery_status = BATTERY_STATUS_CHARGING;
@@ -260,8 +256,9 @@ int acpi_read (int battery, apm_info *info) {
else if (state[0] == 'c') { /* not charging, so must be critical */
info->battery_status = BATTERY_STATUS_CRITICAL;
}
- else
+ else {
fprintf(stderr, "unknown battery state: %s\n", state);
+ }
}
else {
/* Battery state unknown. */
diff --git a/debian/changelog b/debian/changelog
index 6e64fea..d696424 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+wmbattery (2.04) unstable; urgency=low
+
+ * Work around stupid ACPI output format bug. Critical battery detection
+ now works.
+
+ -- Joey Hess <joeyh at debian.org> Mon, 8 Apr 2002 22:49:43 -0400
+
+wmbattery (2.03) unstable; urgency=low
+
+ * Better error reporting.
+
+ -- Joey Hess <joeyh at debian.org> Sun, 7 Apr 2002 22:57:17 -0400
+
wmbattery (2.02) unstable; urgency=medium
* Improved acpi interface (also used for procmeter3 module now).
diff --git a/wmbattery.c b/wmbattery.c
index e5c4d98..c8e777e 100644
--- a/wmbattery.c
+++ b/wmbattery.c
@@ -412,7 +412,7 @@ int main(int argc, char *argv[]) {
delay = 1;
}
/* Check for ACPI support. */
- else if (acpi_supported()) {
+ else if (acpi_supported() && acpi_batt_count > 0) {
if (battnum > acpi_batt_count || battnum < 1) {
error("There %s only %i batter%s, and you asked for number %i.",
acpi_batt_count == 1 ? "is" : "are",
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git
More information about the Pkg-wmaker-commits
mailing list