Xinqi Bao's Git
projects
/
slstatus.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
Fix whitespace
[slstatus.git]
/
components
/
battery.c
diff --git
a/components/battery.c
b/components/battery.c
index
31c7d48
..
1178f20
100644
(file)
--- a/
components/battery.c
+++ b/
components/battery.c
@@
-5,8
+5,8
@@
#include "../util.h"
#if defined(__linux__)
#include "../util.h"
#if defined(__linux__)
- #include <inttypes.h>
#include <limits.h>
#include <limits.h>
+ #include <stdint.h>
#include <unistd.h>
static const char *
#include <unistd.h>
static const char *
@@
-33,8
+33,7
@@
char path[PATH_MAX];
if (esnprintf(path, sizeof(path),
char path[PATH_MAX];
if (esnprintf(path, sizeof(path),
- "/sys/class/power_supply/%s/capacity",
- bat) < 0) {
+ "/sys/class/power_supply/%s/capacity", bat) < 0) {
return NULL;
}
if (pscanf(path, "%d", &perc) != 1) {
return NULL;
}
if (pscanf(path, "%d", &perc) != 1) {
@@
-58,8
+57,7
@@
char path[PATH_MAX], state[12];
if (esnprintf(path, sizeof(path),
char path[PATH_MAX], state[12];
if (esnprintf(path, sizeof(path),
- "/sys/class/power_supply/%s/status",
- bat) < 0) {
+ "/sys/class/power_supply/%s/status", bat) < 0) {
return NULL;
}
if (pscanf(path, "%12s", state) != 1) {
return NULL;
}
if (pscanf(path, "%12s", state) != 1) {
@@
-77,13
+75,12
@@
const char *
battery_remaining(const char *bat)
{
const char *
battery_remaining(const char *bat)
{
- uint
64
_t charge_now, current_now, m, h;
+ uint
max
_t charge_now, current_now, m, h;
double timeleft;
char path[PATH_MAX], state[12];
if (esnprintf(path, sizeof(path),
double timeleft;
char path[PATH_MAX], state[12];
if (esnprintf(path, sizeof(path),
- "/sys/class/power_supply/%s/status",
- bat) < 0) {
+ "/sys/class/power_supply/%s/status", bat) < 0) {
return NULL;
}
if (pscanf(path, "%12s", state) != 1) {
return NULL;
}
if (pscanf(path, "%12s", state) != 1) {
@@
-91,9
+88,9
@@
}
if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
}
if (!pick(bat, "/sys/class/power_supply/%s/charge_now",
- "/sys/class/power_supply/%s/energy_now",
-
path,
sizeof(path)) ||
- pscanf(path, "%
" PRIu64
, &charge_now) < 0) {
+ "/sys/class/power_supply/%s/energy_now",
path,
+ sizeof(path)) ||
+ pscanf(path, "%
ju"
, &charge_now) < 0) {
return NULL;
}
return NULL;
}
@@
-101,7
+98,7
@@
if (!pick(bat, "/sys/class/power_supply/%s/current_now",
"/sys/class/power_supply/%s/power_now", path,
sizeof(path)) ||
if (!pick(bat, "/sys/class/power_supply/%s/current_now",
"/sys/class/power_supply/%s/power_now", path,
sizeof(path)) ||
- pscanf(path, "%
" PRIu64
, ¤t_now) < 0) {
+ pscanf(path, "%
ju"
, ¤t_now) < 0) {
return NULL;
}
return NULL;
}
@@
-113,7
+110,7
@@
h = timeleft;
m = (timeleft - (double)h) * 60;
h = timeleft;
m = (timeleft - (double)h) * 60;
- return bprintf("%
" PRIu64 "h %" PRIu64 "
m", h, m);
+ return bprintf("%
juh %ju
m", h, m);
}
return "";
}
return "";