Introduction
Introduction Statistics Contact Development Disclaimer Help
tImplement temperature plugin for Linux - spoon - dwm status utility (2f30 fork)
git clone git://src.adamsgaard.dk/spoon
Log
Files
Refs
LICENSE
---
commit e5f8bc81916adcaf337d83a4e89f2fd89c7238f5
parent 315c36f57ada6030ca250fb103df80d8fffadb51
Author: sin <[email protected]>
Date: Thu, 13 Oct 2016 16:03:11 +0100
Implement temperature plugin for Linux
Diffstat:
M Makefile | 3 ++-
M temp.c | 14 +++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/Makefile b/Makefile
t@@ -12,7 +12,8 @@ include config.mk
CPPFLAGS_OpenBSD = -I/usr/X11R6/include -I/usr/local/include
LDFLAGS_OpenBSD = -L/usr/X11R6/lib -L/usr/local/lib
CPPFLAGS_Linux = -DPATH_BAT_CAP=\"/sys/class/power_supply/BAT0/capacity\"\
- -DPATH_AC_ONLINE=\"/sys/class/power_supply/AC/online\"
+ -DPATH_AC_ONLINE=\"/sys/class/power_supply/AC/online\"\
+ -DPATH_TEMP=\"/sys/class/hwmon/hwmon0/temp1_input\"
CPPFLAGS = $(CPPFLAGS_$(UNAME))
LDFLAGS = $(LDFLAGS_$(UNAME))
LDLIBS = -lxkbfile -lX11 -lmpdclient
diff --git a/temp.c b/temp.c
t@@ -1,3 +1,4 @@
+#include <err.h>
#include <stddef.h>
#include <stdio.h>
t@@ -27,6 +28,17 @@ tempread(char *buf, size_t len)
int
tempread(char *buf, size_t len)
{
- return -1;
+ FILE *fp;
+ int temp;
+
+ fp = fopen(PATH_TEMP, "r");
+ if (fp == NULL) {
+ warn("fopen %s", PATH_TEMP);
+ return -1;
+ }
+ fscanf(fp, "%d", &temp);
+ fclose(fp);
+ snprintf(buf, len, "%ddegC", temp / 1000);
+ return 0;
}
#endif
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.