sites

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit d6c8c17b8c013a1fb22a22e1417deac458f5904e
parent 4e97e7cecf5942f7ca658a798797e285d74547db
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 28 Jul 2012 11:05:59 +0200

A temperature helper function for dwmstatus.
Diffstat:
Adwm.suckless.org/dwmstatus/dwmstatus-temperature.c | 15+++++++++++++++
Mdwm.suckless.org/dwmstatus/index.md | 1+
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/dwmstatus/dwmstatus-temperature.c b/dwm.suckless.org/dwmstatus/dwmstatus-temperature.c @@ -0,0 +1,15 @@ +/* + * gettemperature("/sys/class/hwmon/hwmon0/device", "temp1_input"); + */ + +char * +gettemperature(char *base, char *sensor) +{ + char *co; + + co = readfile(base, sensor); + if (co == NULL) + return smprintf(""); + return smprintf("%02.0f°C", atof(co) / 1000); +} + diff --git a/dwm.suckless.org/dwmstatus/index.md b/dwm.suckless.org/dwmstatus/index.md @@ -29,4 +29,5 @@ If you have simple C functions for gathering system information, please add them here as file or as code example. * [Support for ACPI battery status Linux](new-acpi-battery.c) +* [Reading out a temperature from /sys](dwmstatus-temperature.c)