Build Linux-only functions only on Linux
Aaron Marcher me@drkhsh.at
Sun, 18 Mar 2018 23:26:13 +0100
10 files changed,
20 insertions(+),
0 deletions(-)
M
components/battery.c
→
components/battery.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <limits.h> #include <stdio.h> #include <string.h>@@ -54,3 +55,4 @@ }
} return (i == LEN(map)) ? "?" : map[i].symbol; } +#endif
M
components/cpu.c
→
components/cpu.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <stdio.h> #include <string.h>@@ -61,3 +62,4 @@ ((b[0]+b[1]+b[2]+b[3]+b[4]+b[5]+b[6]) - (a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]));
return bprintf("%d", perc); } +#endif
M
components/entropy.c
→
components/entropy.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <stdio.h> #include "../util.h"@@ -11,3 +12,4 @@
return (pscanf("/proc/sys/kernel/random/entropy_avail", "%d", &num) == 1) ? bprintf("%d", num) : NULL; } +#endif
M
components/ip.c
→
components/ip.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <err.h> #include <ifaddrs.h> #include <netdb.h>@@ -68,3 +69,4 @@ freeifaddrs(ifaddr);
return NULL; } +#endif
M
components/ram.c
→
components/ram.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <stdio.h> #include "../util.h"@@ -50,3 +51,4 @@ &total, &free, &buffers, &buffers, &cached) == 5) ?
bprintf("%f", (float)(total - free - buffers - cached) / 1024 / 1024) : NULL; } +#endif
M
components/swap.c
→
components/swap.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <err.h> #include <stdio.h> #include <string.h>@@ -134,3 +135,4 @@ sscanf(match, "SwapFree: %ld kB\n", &free);
return bprintf("%f", (float)(total - free - cached) / 1024 / 1024); } +#endif
M
components/temperature.c
→
components/temperature.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <stdio.h> #include "../util.h"@@ -11,3 +12,4 @@
return (pscanf(file, "%d", &temp) == 1) ? bprintf("%d", temp / 1000) : NULL; } +#endif
M
components/uptime.c
→
components/uptime.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <sys/sysinfo.h> #include "../util.h"@@ -16,3 +17,4 @@ m = (info.uptime - h * 3600 ) / 60;
return bprintf("%dh %dm", h, m); } +#endif
M
components/volume.c
→
components/volume.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <err.h> #include <fcntl.h> #include <sys/soundcard.h>@@ -41,3 +42,4 @@ close(afd);
return bprintf("%d", v & 0xff); } +#endif
M
components/wifi.c
→
components/wifi.c
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */ +#ifdef __linux__ #include <err.h> #include <ifaddrs.h> #include <linux/wireless.h>@@ -88,3 +89,4 @@ return NULL;
else return id; } +#endif