Improve battery meter support (thanks to Richard W.) Closes #3063541.

This commit is contained in:
Hisham Muhammad 2010-11-20 19:13:12 +00:00
parent 5fd1436a92
commit 3fcbcbfda6
2 changed files with 24 additions and 3 deletions

View File

@ -234,7 +234,6 @@ static double getProcBatData() {
return 0; return 0;
double percent = totalFull > 0 ? ((double) totalRemain * 100) / (double) totalFull : 0; double percent = totalFull > 0 ? ((double) totalRemain * 100) / (double) totalFull : 0;
return percent; return percent;
} }
@ -270,8 +269,27 @@ static double getSysBatData() {
return 0; return 0;
} }
totalFull += parseUevent(file, "POWER_SUPPLY_ENERGY_FULL="); if ((totalFull += parseUevent(file, "POWER_SUPPLY_ENERGY_FULL="))) {
totalRemain += parseUevent(file, "POWER_SUPPLY_ENERGY_NOW="); totalRemain += parseUevent(file, "POWER_SUPPLY_ENERGY_NOW=");
} else {
//reset file pointer
if (fseek(file, 0, SEEK_SET) < 0) {
fclose(file);
return 0;
}
}
//Some systems have it as CHARGE instead of ENERGY.
if ((totalFull += parseUevent(file, "POWER_SUPPLY_CHARGE_FULL="))) {
totalRemain += parseUevent(file, "POWER_SUPPLY_CHARGE_NOW=");
} else {
//reset file pointer
if (fseek(file, 0, SEEK_SET) < 0) {
fclose(file);
return 0;
}
}
fclose(file); fclose(file);
} }
@ -282,6 +300,7 @@ static double getSysBatData() {
static void BatteryMeter_setValues(Meter * this, char *buffer, int len) { static void BatteryMeter_setValues(Meter * this, char *buffer, int len) {
double percent = getProcBatData(); double percent = getProcBatData();
if (percent == 0) { if (percent == 0) {
percent = getSysBatData(); percent = getSysBatData();
if (percent == 0) { if (percent == 0) {

View File

@ -20,6 +20,8 @@ What's new in version 0.9
(thanks to Pavol Rusnak) (thanks to Pavol Rusnak)
* Add Bash/emacs style navigation keys * Add Bash/emacs style navigation keys
(thanks to Daniel Schuler) (thanks to Daniel Schuler)
* Improve battery meter support
(thanks to Richard W.)
* Fix IO-wait color in "Black on White" scheme * Fix IO-wait color in "Black on White" scheme
What's new in version 0.8.3 What's new in version 0.8.3