Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
3fcbcbfd
Commit
3fcbcbfd
authored
Nov 20, 2010
by
Hisham Muhammad
Browse files
Improve battery meter support (thanks to Richard W.) Closes #3063541.
parent
5fd1436a
Changes
2
Hide whitespace changes
Inline
Side-by-side
BatteryMeter.c
View file @
3fcbcbfd
...
...
@@ -234,7 +234,6 @@ static double getProcBatData() {
return
0
;
double
percent
=
totalFull
>
0
?
((
double
)
totalRemain
*
100
)
/
(
double
)
totalFull
:
0
;
return
percent
;
}
...
...
@@ -270,8 +269,27 @@ static double getSysBatData() {
return
0
;
}
totalFull
+=
parseUevent
(
file
,
"POWER_SUPPLY_ENERGY_FULL="
);
totalRemain
+=
parseUevent
(
file
,
"POWER_SUPPLY_ENERGY_NOW="
);
if
((
totalFull
+=
parseUevent
(
file
,
"POWER_SUPPLY_ENERGY_FULL="
)))
{
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
);
}
...
...
@@ -282,6 +300,7 @@ static double getSysBatData() {
static
void
BatteryMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
len
)
{
double
percent
=
getProcBatData
();
if
(
percent
==
0
)
{
percent
=
getSysBatData
();
if
(
percent
==
0
)
{
...
...
ChangeLog
View file @
3fcbcbfd
...
...
@@ -20,6 +20,8 @@ What's new in version 0.9
(thanks to Pavol Rusnak)
* Add Bash/emacs style navigation keys
(thanks to Daniel Schuler)
* Improve battery meter support
(thanks to Richard W.)
* Fix IO-wait color in "Black on White" scheme
What's new in version 0.8.3
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment