spoon

set dwm status
git clone git://git.2f30.org/spoon.git
Log | Files | Refs | LICENSE

commit 73d2f4ed504a341a3d2fbefb14d2048ff1987edf
parent 9a248ae02783160a7d78adc151d065f3276055c1
Author: Christoph Polcin <labs@polcin.de>
Date:   Wed, 14 Mar 2018 09:06:41 +0100

Configure battery from args

Signed-off-by: Christoph Polcin <labs@polcin.de>

Diffstat:
Makefile | 2--
batt.c | 10++++++----
config.def.h | 2+-
types.h | 5+++++
4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -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 @@ -1,6 +1,7 @@ #include <err.h> #include <stdio.h> +#include "types.h" #include "util.h" char *crit[] = { @@ -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 @@ -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 = &(struct battarg){ .cap = "/sys/class/power_supply/BAT0/capacity", .ac = "/sys/class/power_supply/AC/online" } }, { .fmt = "%s ", .read = wifiread, .arg = NULL }, { .fmt = "[%s] ", .read = xkblayoutread, .arg = NULL }, { .fmt = "%s", .read = keyread, .arg = &(struct keyarg){ .sym = XK_Caps_Lock, .on = "[caps] ", .off = "" } }, diff --git a/types.h b/types.h @@ -1,3 +1,8 @@ +struct battarg { + char *cap; + char *ac; +}; + struct mpdarg { char *host; unsigned int port;