Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osdd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
osdd
Commits
d2d774b5
Commit
d2d774b5
authored
9 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
osd-batt: Newer kernels use different file names in /sys
parent
7a109548
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
osd-batt.c
+14
-4
14 additions, 4 deletions
osd-batt.c
with
14 additions
and
4 deletions
osd-batt.c
+
14
−
4
View file @
d2d774b5
/*
* A Simple Battery Status Display via OSD
*
* (c) 2007--201
2
Martin Mares <mj@ucw.cz>
* (c) 2007--201
5
Martin Mares <mj@ucw.cz>
*/
#undef DEBUG
...
...
@@ -67,6 +67,16 @@ static int sys_read_int(char *attribute, int default_value)
return
atoi
(
buf
);
}
static
int
sys_read_int_variant
(
char
*
attr1
,
char
*
attr2
,
int
default_value
)
{
char
buf
[
BUFSIZE
];
if
(
sys_read
(
buf
,
attr1
)
&&
buf
[
0
]
||
sys_read
(
buf
,
attr2
)
&&
buf
[
0
])
return
atoi
(
buf
);
else
return
default_value
;
}
static
void
parse_ac
(
void
)
{
ac_online
=
sys_read_int
(
"online"
,
0
);
...
...
@@ -97,9 +107,9 @@ static void parse_batt(char *batt_name)
char
status
[
BUFSIZE
];
int
charging
=
sys_read
(
status
,
"status"
)
&&
!
strcmp
(
status
,
"Charging"
);
int
charge_full
=
sys_read_int
(
"charge_full"
,
0
);
int
charge_now
=
sys_read_int
(
"charge_now"
,
0
);
int
current_now
=
sys_read_int
(
"current_now"
,
0
);
int
charge_full
=
sys_read_int
_variant
(
"energy_full"
,
"charge_full"
,
0
);
int
charge_now
=
sys_read_int
_variant
(
"energy_now"
,
"charge_now"
,
0
);
int
current_now
=
sys_read_int
_variant
(
"power_now"
,
"current_now"
,
0
);
present_mask
|=
1
<<
batt_id
;
total_now
+=
charge_now
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment