[hackers] [slstatus] battery: Separate function for readbility || Aaron Marcher

From: <git_AT_suckless.org>
Date: Sun, 29 Apr 2018 20:06:53 +0200 (CEST)

commit 09950055baa8ef17ba3ccee8bbe391de3110cc6f
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Sun Apr 29 20:02:42 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Sun Apr 29 20:02:42 2018 +0200

    battery: Separate function for readbility

diff --git a/components/battery.c b/components/battery.c
index 75f2945..955d8ab 100644
--- a/components/battery.c
+++ b/components/battery.c
_AT_@ -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;
 
_AT_@ -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 *
Received on Sun Apr 29 2018 - 20:06:53 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 29 2018 - 20:12:35 CEST