--- xosview-1.8.2.orig/linux/btrymeter.cc
+++ xosview-1.8.2/linux/btrymeter.cc
@@ -44,10 +44,16 @@
if (getapminfo() || getacpiinfo())
return;
- std::cerr <<"Cannot get battery information" << std::endl;
- std::cerr <<"If using APM, have you loaded the `apm' module?" << std::endl;
- std::cerr <<"If using ACPI, have you loaded the `battery' module?" << std::endl;
- parent_->done(1);
+ // We can hit this spot in any of two cases:
+ // - We have an ACPI system and the battery is removed
+ // - We have neither ACPI nor APM in the system
+ // We report an empty battery (i.e., we are running off AC power) instead of
+ // original behavior of just exiting the program.
+ // (Refer to Debian bug report #281565)
+ total_ = 100;
+ fields_[0] = 0;
+ fields_[1] = 100;
+ setUsed(fields_[0], total_);
}
@@ -62,6 +68,12 @@
char buff[256];
loadinfo >> buff >> buff >> buff >> buff >> buff >> buff >> fields_[0];
+ // If the battery status is reported as a negative number, it means we are
+ // running on AC power and no battery status is available - Report it as
+ // completely empty (0). (Refer to Debian bug report #281565)
+ if (fields_[0] < 0)
+ fields_[0] = 0;
+
total_ = 100;
fields_[1] = total_ - fields_[0];
syntax highlighted by Code2HTML, v. 0.9.1