X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fprint_cpu_temperature.c;h=01744a14fac57293768b163bd545fa6f0229904f;hb=0e4fd9ad4a4cc7d6c770134a077e91b02f6cd2f0;hp=431664ed9d0f2ccbe47535b0945ef70f3a76619e;hpb=82d25dc36295bc59cdf37af8e23c644a9c2e6aad;p=i3%2Fi3status diff --git a/src/print_cpu_temperature.c b/src/print_cpu_temperature.c index 431664e..01744a1 100644 --- a/src/print_cpu_temperature.c +++ b/src/print_cpu_temperature.c @@ -1,4 +1,5 @@ // vim:ts=4:sw=4:expandtab +#include #include #include #include @@ -52,7 +53,7 @@ typedef struct temperature_s { #define ERROR_CODE 1 static int read_temperature(char *thermal_zone, temperature_t *temperature) { -#if defined(LINUX) +#if defined(__linux__) static char buf[16]; long int temp; @@ -223,7 +224,7 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const asprintf(&thermal_zone, THERMAL_ZONE, zone); else { static glob_t globbuf; - if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0) + if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) != 0) die("glob() failed\n"); if (globbuf.gl_pathc == 0) { /* No glob matches, the specified path does not contain a wildcard. */ @@ -250,11 +251,13 @@ void print_cpu_temperature_info(yajl_gen json_gen, char *buffer, int zone, const for (walk = selected_format; *walk != '\0'; walk++) { if (*walk != '%') { *(outwalk++) = *walk; - continue; - } - if (BEGINS_WITH(walk + 1, "degrees")) { + + } else if (BEGINS_WITH(walk + 1, "degrees")) { outwalk += sprintf(outwalk, "%s", temperature.formatted_value); walk += strlen("degrees"); + + } else { + *(outwalk++) = '%'; } }