summaryrefslogtreecommitdiff
path: root/src/status/temp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/status/temp.c')
-rw-r--r--src/status/temp.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/status/temp.c b/src/status/temp.c
index e6763d0..c102fcd 100644
--- a/src/status/temp.c
+++ b/src/status/temp.c
@@ -2,15 +2,22 @@
#include <fcntl.h>
#include <unistd.h>
-#include "status/temp.h"
+#include "common.h"
#include "tools.h"
-void status_temp(char *title, char *sysfile)
+void status_temp(GlobalData *g, char *title, char *sysfile)
{
+ StatusItem s;
+ char text[16] = { 0 };
+
char stline[16];
ssize_t stlen;
+
+ statusitem_init(&s);
+ s.text = text;
+
stlen = fileRead(stline, sizeof(stline), sysfile);
if (stlen <= 0) {
return;
@@ -21,16 +28,14 @@ void status_temp(char *title, char *sysfile)
* Sometimes we get garbage from sysfs...
*/
if (stlen < 6 || stlen > 7) {
- printf(" ^fg(red)%sERROR ", title);
- return;
+ s.color = "red";
+ snprintf(text, sizeof(text), "%sERROR", title);
+ } else {
+ stline[stlen - 4] = '\0';
+
+ s.color = "#FF33FF";
+ snprintf(text, sizeof(text), "%s%s°C", title, stline);
}
- fputs(" ^fg(#FF33FF)", stdout);
- fputs(title, stdout);
- fwrite(stline, 1, stlen - 4, stdout);
- /*
- fputs(".", stdout);
- fwrite(&stline[stlen - 3], 1, 1, stdout);
- */
- fputs("°C ", stdout);
+ line_append_item(g, &s);
}