tConfigure battery from args - spoon - dwm status utility (2f30 fork) | |
git clone git://src.adamsgaard.dk/spoon | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 73d2f4ed504a341a3d2fbefb14d2048ff1987edf | |
parent 9a248ae02783160a7d78adc151d065f3276055c1 | |
Author: Christoph Polcin <[email protected]> | |
Date: Wed, 14 Mar 2018 09:06:41 +0100 | |
Configure battery from args | |
Signed-off-by: Christoph Polcin <[email protected]> | |
Diffstat: | |
M Makefile | 2 -- | |
M batt.c | 10 ++++++---- | |
M config.def.h | 2 +- | |
M types.h | 5 +++++ | |
4 files changed, 12 insertions(+), 7 deletions(-) | |
--- | |
diff --git a/Makefile b/Makefile | |
t@@ -13,8 +13,6 @@ CPPFLAGS_OpenBSD = -I/usr/X11R6/include -I/usr/local/include | |
LDFLAGS_OpenBSD = -L/usr/X11R6/lib -L/usr/local/lib | |
CPPFLAGS_Linux =\ | |
-I/usr/local/include\ | |
- -DPATH_BAT_CAP=\"/sys/class/power_supply/BAT0/capacity\"\ | |
- -DPATH_AC_ONLINE=\"/sys/class/power_supply/AC/online\"\ | |
-DPATH_TEMP=\"/sys/class/hwmon/hwmon1/temp1_input\"\ | |
-DPATH_CPU_FREQ=\"/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq\" | |
CPPFLAGS = $(CPPFLAGS_$(UNAME)) | |
diff --git a/batt.c b/batt.c | |
t@@ -1,6 +1,7 @@ | |
#include <err.h> | |
#include <stdio.h> | |
+#include "types.h" | |
#include "util.h" | |
char *crit[] = { | |
t@@ -65,17 +66,18 @@ battread(void *arg, char *buf, size_t len) | |
FILE *fp; | |
int acon; | |
int life; | |
+ struct battarg *battarg = arg; | |
- fp = fopen(PATH_BAT_CAP, "r"); | |
+ fp = fopen(battarg->cap, "r"); | |
if (fp == NULL) { | |
- warn("fopen %s", PATH_BAT_CAP); | |
+ warn("fopen %s", battarg->cap); | |
return -1; | |
} | |
fscanf(fp, "%d", &life); | |
fclose(fp); | |
- fp = fopen(PATH_AC_ONLINE, "r"); | |
+ fp = fopen(battarg->ac, "r"); | |
if (fp == NULL) { | |
- warn("fopen %s", PATH_AC_ONLINE); | |
+ warn("fopen %s", battarg->ac); | |
return -1; | |
} | |
fscanf(fp, "%d", &acon); | |
diff --git a/config.def.h b/config.def.h | |
t@@ -8,7 +8,7 @@ struct ent ents[] = { | |
{ .fmt = "[%s] ", .read = loadread, .arg = NULL }, | |
{ .fmt = "[%s] ", .read = cpuread, .arg = NULL }, | |
{ .fmt = "[%s] ", .read = tempread, .arg = NULL }, | |
- { .fmt = "%s ", .read = battread, .arg = NULL }, | |
+ { .fmt = "%s ", .read = battread, .arg = &(struc… | |
{ .fmt = "%s ", .read = wifiread, .arg = NULL }, | |
{ .fmt = "[%s] ", .read = xkblayoutread, .arg = NULL }, | |
{ .fmt = "%s", .read = keyread, .arg = &(struct … | |
diff --git a/types.h b/types.h | |
t@@ -1,3 +1,8 @@ | |
+struct battarg { | |
+ char *cap; | |
+ char *ac; | |
+}; | |
+ | |
struct mpdarg { | |
char *host; | |
unsigned int port; |