Xinqi Bao's Git
projects
/
slstatus.git
/ commitdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
patch
|
inline
| side by side (from parent 1:
cee6811
)
battery: Separate function for readbility
author
Aaron Marcher <
[email protected]
>
Sun, 29 Apr 2018 18:02:42 +0000
(20:02 +0200)
committer
Aaron Marcher <
[email protected]
>
Sun, 29 Apr 2018 18:02:42 +0000
(20:02 +0200)
components/battery.c
patch
|
blob
|
history
diff --git
a/components/battery.c
b/components/battery.c
index
75f2945
..
955d8ab
100644
(file)
--- a/
components/battery.c
+++ b/
components/battery.c
@@
-14,17
+14,21
@@
#include "../util.h"
#include "../util.h"
+#if defined(__linux__)
const char *
battery_perc(const char *bat)
{
const char *
battery_perc(const char *bat)
{
-#if defined(__linux__)
int perc;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
bprintf("%d", perc) : NULL;
int perc;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
bprintf("%d", perc) : NULL;
+}
#elif defined(__OpenBSD__)
#elif defined(__OpenBSD__)
+const char *
+battery_perc(const char *null)
+{
struct apm_power_info apm_info;
int fd;
struct apm_power_info apm_info;
int fd;
@@
-42,8
+46,8
@@
battery_perc(const char *bat)
close(fd);
return bprintf("%d", apm_info.battery_life);
close(fd);
return bprintf("%d", apm_info.battery_life);
-#endif
}
}
+#endif
#if defined(__linux__)
const char *
#if defined(__linux__)
const char *