X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fui_unity.c;h=0ab2e1290d9517dd90f1471971e830d4c996f4be;hb=9dc8095432b3733157be0c01a41013e640a75f76;hp=2c00403377b4e55bcaedbc48ec4d6ab9b5b88eb8;hpb=17a469b9e2611116bf69662c7ce6dea5799e7d1c;p=psensor.git diff --git a/src/ui_unity.c b/src/ui_unity.c index 2c00403..0ab2e12 100644 --- a/src/ui_unity.c +++ b/src/ui_unity.c @@ -18,6 +18,7 @@ */ #include +#include #include #include @@ -25,6 +26,28 @@ static int initialized; static UnityLauncherEntry *psensor_entry; static unsigned int last_visible = -1; +static double get_max_current_value(struct psensor **sensors, unsigned int type) +{ + double m, v; + struct psensor *s; + + m = UNKNOWN_DBL_VALUE; + while (*sensors) { + s = *sensors; + + if ((s->type & type) && config_is_sensor_graph_enabled(s->id)) { + v = psensor_get_current_value(s); + + if (m == UNKNOWN_DBL_VALUE || v > m) + m = v; + } + + sensors++; + } + + return m; +} + void ui_unity_launcher_entry_update(struct psensor **sensors, unsigned int show, int use_celsius) @@ -50,7 +73,7 @@ void ui_unity_launcher_entry_update(struct psensor **sensors, } if (sensors && *sensors) { - v = psensor_get_max_current_value(sensors, SENSOR_TYPE_TEMP); + v = get_max_current_value(sensors, SENSOR_TYPE_TEMP); if (!use_celsius) v = celsius_to_fahrenheit(v);