parent
47edbfedb0
commit
4350855593
|
@ -744,17 +744,22 @@ _temperature_cb_check(void *data)
|
||||||
Temperature_Face *ef;
|
Temperature_Face *ef;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
Evas_List *therms;
|
Evas_List *therms;
|
||||||
|
int temp = 0;
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
ef = data;
|
ef = data;
|
||||||
therms = e_file_ls("/proc/acpi/thermal_zone");
|
therms = e_file_ls("/proc/acpi/thermal_zone");
|
||||||
if (!therms)
|
if (!therms)
|
||||||
{
|
{
|
||||||
if (ef->have_temp != 0)
|
FILE *f;
|
||||||
|
|
||||||
|
f = fopen("/sys/devices/temperatures/cpu_temperature", "rb");
|
||||||
|
if (f)
|
||||||
{
|
{
|
||||||
/* disable therm object */
|
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||||
edje_object_signal_emit(ef->temp_object, "unknown", "");
|
if (sscanf(buf, "%i", &temp) == 1)
|
||||||
edje_object_part_text_set(ef->temp_object, "reading", "NO TEMP");
|
ret = 1;
|
||||||
ef->have_temp = 0;
|
fclose(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -767,10 +772,9 @@ _temperature_cb_check(void *data)
|
||||||
}
|
}
|
||||||
while (therms)
|
while (therms)
|
||||||
{
|
{
|
||||||
char buf[4096], units[32];
|
char units[32];
|
||||||
char *name;
|
char *name;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int temp = 0;
|
|
||||||
|
|
||||||
name = therms->data;
|
name = therms->data;
|
||||||
therms = evas_list_remove_list(therms, therms);
|
therms = evas_list_remove_list(therms, therms);
|
||||||
|
@ -781,19 +785,36 @@ _temperature_cb_check(void *data)
|
||||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||||
units[0] = 0;
|
units[0] = 0;
|
||||||
if (sscanf(buf, "%*[^:]: %i %20s", &temp, units) == 2)
|
if (sscanf(buf, "%*[^:]: %i %20s", &temp, units) == 2)
|
||||||
{
|
ret = 1;
|
||||||
/* temp == temperature as a double */
|
|
||||||
/* units = string ("C" == celcius, "F" = farenheight) */
|
|
||||||
_temperature_level_set(ef, ((double)temp - ef->temp->conf->low) / ef->temp->conf->high);
|
|
||||||
snprintf(buf, sizeof(buf), "%i°C", temp, units);
|
|
||||||
edje_object_part_text_set(ef->temp_object, "reading", buf);
|
|
||||||
}
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
if (ret)
|
||||||
|
{
|
||||||
|
if (ef->have_temp == 0)
|
||||||
|
{
|
||||||
|
/* enable therm object */
|
||||||
|
edje_object_signal_emit(ef->temp_object, "known", "");
|
||||||
|
ef->have_temp = 1;
|
||||||
|
}
|
||||||
|
_temperature_level_set(ef, ((double)temp - ef->temp->conf->low) / ef->temp->conf->high);
|
||||||
|
snprintf(buf, sizeof(buf), "%i°C", temp);
|
||||||
|
edje_object_part_text_set(ef->temp_object, "reading", buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ef->have_temp != 0)
|
||||||
|
{
|
||||||
|
/* disable therm object */
|
||||||
|
edje_object_signal_emit(ef->temp_object, "unknown", "");
|
||||||
|
edje_object_part_text_set(ef->temp_object, "reading", "NO TEMP");
|
||||||
|
_temperature_level_set(ef, 0.5);
|
||||||
|
ef->have_temp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue