fixed nvidia fan values display.
[psensor.git] / src / main.c
index db4353d..98fc729 100644 (file)
@@ -136,12 +136,14 @@ update_psensor_values_size(struct psensor **sensors, struct config *cfg)
        }
 }
 
-static void update_measures(struct ui_psensor *ui)
+static void *update_measures(void *data)
 {
        struct psensor **sensors;
        struct config *cfg;
        int period;
+       struct ui_psensor *ui;
 
+       ui = (struct ui_psensor *)data;
        cfg = ui->config;
 
        while (1) {
@@ -149,7 +151,7 @@ static void update_measures(struct ui_psensor *ui)
 
                sensors = ui->sensors;
                if (!sensors)
-                       return;
+                       pthread_exit(NULL);
 
                update_psensor_values_size(sensors, cfg);
 
@@ -252,16 +254,16 @@ static void associate_colors(struct psensor **sensors)
        /* number of uniq colors */
 #define COLORS_COUNT 8
 
-       unsigned int colors[COLORS_COUNT][3] = {
-               {0x0000, 0x0000, 0x0000},       /* black */
-               {0xffff, 0x0000, 0x0000},       /* red */
-               {0x0000, 0x0000, 0xffff},       /* blue */
-               {0x0000, 0xffff, 0x0000},       /* green */
+       double colors[COLORS_COUNT][3] = {
+               {0, 0, 0},      /* black */
+               {1, 0, 0},      /* red */
+               {0, 0, 1},      /* blue */
+               {0, 1, 0},      /* green */
 
-               {0x7fff, 0x7fff, 0x7fff},       /* grey */
-               {0x7fff, 0x0000, 0x0000},       /* dark red */
-               {0x0000, 0x0000, 0x7fff},       /* dark blue */
-               {0x0000, 0x7fff, 0x0000}        /* dark green */
+               {0.5, 0.5, 0.5},/* grey */
+               {0.5, 0, 0},    /* dark red */
+               {0, 0, 0.5},    /* dark blue */
+               {0, 0.5, 0}     /* dark green */
        };
        struct psensor **cur;
        int i;
@@ -292,13 +294,8 @@ associate_cb_alarm_raised(struct psensor **sensors, struct ui_psensor *ui)
                s->alarm_low_threshold
                        = config_get_sensor_alarm_low_threshold(s->id);
 
-               if (is_temp_type(s->type) || is_fan_type(s->type)) {
-                       s->alarm_enabled
+               s->alarm_enabled
                            = config_get_sensor_alarm_enabled(s->id);
-               } else {
-                       s->alarm_high_threshold = 0;
-                       s->alarm_enabled = 0;
-               }
 
                sensor_cur++;
        }
@@ -474,9 +471,8 @@ static struct psensor **create_sensors_list(const char *url,
 int main(int argc, char **argv)
 {
        struct ui_psensor ui;
-       GError *error;
-       GThread *thread;
-       int optc, cmdok, opti, use_libatasmart, new_instance;
+       pthread_t thread;
+       int optc, cmdok, opti, use_libatasmart, new_instance, ret;
        char *url = NULL;
        GApplication *app;
 
@@ -590,11 +586,10 @@ int main(int argc, char **argv)
 
        ui_enable_alpha_channel(&ui);
 
-       thread = g_thread_create((GThreadFunc) update_measures,
-                                &ui, TRUE, &error);
+       ret = pthread_create(&thread, NULL, update_measures, &ui);
 
-       if (!thread)
-               g_error_free(error);
+       if (ret)
+               log_err(_("Failed to create thread for monitoring sensors"));
 
        ui.graph_update_interval = ui.config->graph_update_interval;