diff options
author | Aaron Marcher <me@drkhsh.at> | 2018-04-29 20:02:42 +0200 |
---|---|---|
committer | Aaron Marcher <me@drkhsh.at> | 2018-04-29 20:02:42 +0200 |
commit | 09950055baa8ef17ba3ccee8bbe391de3110cc6f (patch) | |
tree | 64d1dcc3ff4dd826375d81ad94f9eff4ae418e52 /components/battery.c | |
parent | cee6811036382215975792af4fa4f1624fc86a43 (diff) |
battery: Separate function for readbility
Diffstat (limited to 'components/battery.c')
-rw-r--r-- | components/battery.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/components/battery.c b/components/battery.c index 75f2945..955d8ab 100644 --- a/components/battery.c +++ b/components/battery.c @@ -14,17 +14,21 @@ #include "../util.h" +#if defined(__linux__) 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; +} #elif defined(__OpenBSD__) +const char * +battery_perc(const char *null) +{ 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); -#endif } +#endif #if defined(__linux__) const char * |