forked from enlightenment/enlightenment
Only check the type of sensor on init and when changing config.
SVN revision: 27464
This commit is contained in:
parent
6e5deedf2c
commit
2a1358264a
|
@ -29,7 +29,7 @@ struct _E_Config_Dialog_Data
|
|||
int high_temp;
|
||||
|
||||
int sensor;
|
||||
int acpizone;
|
||||
Ecore_List *sensors;
|
||||
};
|
||||
|
||||
/* Protos */
|
||||
|
@ -69,6 +69,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
{
|
||||
double p;
|
||||
Ecore_List *therms;
|
||||
char *name;
|
||||
|
||||
cfdata->units = temperature_config->units;
|
||||
if (temperature_config->units == CELCIUS)
|
||||
|
@ -110,34 +111,46 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
cfdata->high_method = TEMP_HIGH_HIGH;
|
||||
|
||||
cfdata->sensor = 0;
|
||||
if (temperature_config->sensor_name)
|
||||
switch (temperature_config->sensor_type)
|
||||
{
|
||||
if (!strcmp(temperature_config->sensor_name, "temp1"))
|
||||
cfdata->sensor = 0;
|
||||
else if (!strcmp(temperature_config->sensor_name, "temp2"))
|
||||
cfdata->sensor = 1;
|
||||
else if (!strcmp(temperature_config->sensor_name, "temp3"))
|
||||
cfdata->sensor = 2;
|
||||
case SENSOR_TYPE_NONE:
|
||||
break;
|
||||
case SENSOR_TYPE_FREEBSD:
|
||||
break;
|
||||
case SENSOR_TYPE_OMNIBOOK:
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_MACMINI:
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_I2C:
|
||||
ecore_list_append(cfdata->sensors, strdup("temp1"));
|
||||
ecore_list_append(cfdata->sensors, strdup("temp2"));
|
||||
ecore_list_append(cfdata->sensors, strdup("temp3"));
|
||||
ecore_list_goto_first(cfdata->sensors);
|
||||
while ((name = ecore_list_next(cfdata->sensors)))
|
||||
{
|
||||
if (!strcmp(temperature_config->sensor_name, name))
|
||||
break;
|
||||
cfdata->sensor++;
|
||||
}
|
||||
cfdata->acpizone = 0;
|
||||
if (temperature_config->acpi_sel)
|
||||
{
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_ACPI:
|
||||
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
||||
if (therms)
|
||||
{
|
||||
char *tzone;
|
||||
int n = 0;
|
||||
while ((tzone = ecore_list_next(therms)))
|
||||
|
||||
while ((name = ecore_list_next(therms)))
|
||||
{
|
||||
if (!strcmp(temperature_config->acpi_sel, tzone))
|
||||
ecore_list_append(cfdata->sensors, strdup(name));
|
||||
if (!strcmp(temperature_config->sensor_name, name))
|
||||
{
|
||||
cfdata->acpizone = n;
|
||||
break;
|
||||
cfdata->sensor = n;
|
||||
}
|
||||
else n++;
|
||||
n++;
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +160,8 @@ _create_data(E_Config_Dialog *cfd)
|
|||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||
cfdata->sensors = ecore_list_new();
|
||||
ecore_list_set_free_cb(cfdata->sensors, free);
|
||||
_fill_data(cfdata);
|
||||
return cfdata;
|
||||
}
|
||||
|
@ -155,6 +170,8 @@ static void
|
|||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
temperature_config->config_dialog = NULL;
|
||||
if (cfdata->sensors) ecore_list_destroy(cfdata->sensors);
|
||||
cfdata->sensors = NULL;
|
||||
free(cfdata);
|
||||
}
|
||||
|
||||
|
@ -276,57 +293,24 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
Ecore_List *therms;
|
||||
|
||||
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
||||
if ((!therms) || (ecore_list_is_empty(therms)))
|
||||
if (!ecore_list_is_empty(cfdata->sensors))
|
||||
{
|
||||
FILE *f;
|
||||
/* TODO: Notify user which thermal system is in use */
|
||||
/* TODO: Let the user choose the wanted thermal system */
|
||||
char *name;
|
||||
int n = 0;
|
||||
|
||||
if (therms)
|
||||
{
|
||||
ecore_list_destroy(therms);
|
||||
therms = NULL;
|
||||
}
|
||||
|
||||
f = fopen("/sys/devices/temperatures/cpu_temperature", "rb");
|
||||
if (f) fclose(f);
|
||||
|
||||
if (!f)
|
||||
{
|
||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||
if ((therms) && (!ecore_list_is_empty(therms)))
|
||||
{
|
||||
of = e_widget_framelist_add(evas, _("Sensors"), 0);
|
||||
rg = e_widget_radio_group_new(&(cfdata->sensor));
|
||||
ob = e_widget_radio_add(evas, _("Temp 1"), 0, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Temp 2"), 1, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
ob = e_widget_radio_add(evas, _("Temp 3"), 2, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
}
|
||||
if (therms) ecore_list_destroy(therms);
|
||||
}
|
||||
}
|
||||
else
|
||||
ecore_list_goto_first(cfdata->sensors);
|
||||
while ((name = ecore_list_next(cfdata->sensors)))
|
||||
{
|
||||
of = e_widget_framelist_add(evas, _("ACPI Temperature"), 0);
|
||||
rg = e_widget_radio_group_new(&(cfdata->acpizone));
|
||||
char *tzone;
|
||||
int n = 0;
|
||||
while ((tzone = ecore_list_next(therms)))
|
||||
{
|
||||
ob = e_widget_radio_add(evas, _(tzone), n, rg);
|
||||
ob = e_widget_radio_add(evas, _(name), n, rg);
|
||||
e_widget_framelist_object_append(of, ob);
|
||||
n++;
|
||||
}
|
||||
e_widget_list_object_append(o, of, 1, 1, 0.5);
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
#endif
|
||||
|
||||
of = e_widget_framelist_add(evas, _("Check Interval"), 0);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.1f seconds"), 0.5, 1000.0, 0.5, 0, &(cfdata->poll_time), NULL, 200);
|
||||
|
@ -378,10 +362,6 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
static int
|
||||
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
int n = 0;
|
||||
Ecore_List *therms;
|
||||
char *tzone;
|
||||
|
||||
if (cfdata->unit_method != temperature_config->units)
|
||||
{
|
||||
if (cfdata->unit_method == 0)
|
||||
|
@ -404,36 +384,12 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
temperature_config->high = cfdata->high_temp;
|
||||
if (temperature_config->sensor_name)
|
||||
evas_stringshare_del(temperature_config->sensor_name);
|
||||
temperature_config->sensor_name = NULL;
|
||||
switch (cfdata->sensor)
|
||||
{
|
||||
case 0:
|
||||
temperature_config->sensor_name = evas_stringshare_add("temp1");
|
||||
break;
|
||||
case 1:
|
||||
temperature_config->sensor_name = evas_stringshare_add("temp2");
|
||||
break;
|
||||
case 2:
|
||||
temperature_config->sensor_name = evas_stringshare_add("temp3");
|
||||
break;
|
||||
}
|
||||
if (temperature_config->acpi_sel)
|
||||
evas_stringshare_del(temperature_config->acpi_sel);
|
||||
temperature_config->acpi_sel = NULL;
|
||||
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
||||
if (therms)
|
||||
{
|
||||
while ((tzone = ecore_list_next(therms)))
|
||||
{
|
||||
if (n == cfdata->acpizone)
|
||||
{
|
||||
temperature_config->acpi_sel = evas_stringshare_add(tzone);
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
temperature_config->sensor_name =
|
||||
evas_stringshare_add(ecore_list_goto_index(cfdata->sensors, cfdata->sensor));
|
||||
if (temperature_config->sensor_path)
|
||||
evas_stringshare_del(temperature_config->sensor_path);
|
||||
temperature_config->sensor_path = NULL;
|
||||
|
||||
_temperature_face_cb_config_updated();
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
|
|
|
@ -44,6 +44,7 @@ struct _Instance
|
|||
|
||||
static void _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static void _menu_cb_post(void *data, E_Menu *m);
|
||||
static void _temperature_sensor_init(void);
|
||||
static int _temperature_cb_check(void *data);
|
||||
static void _temperature_face_level_set(Instance *inst, double level);
|
||||
static void _temperature_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||
|
@ -169,52 +170,42 @@ _menu_cb_post(void *data, E_Menu *m)
|
|||
temperature_config->menu = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
_temperature_cb_check(void *data)
|
||||
static void
|
||||
_temperature_sensor_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
Instance *inst;
|
||||
Ecore_List *therms;
|
||||
Evas_List *l;
|
||||
int temp = 0;
|
||||
char buf[4096];
|
||||
char path[PATH_MAX];
|
||||
#ifdef __FreeBSD__
|
||||
static int mib[5] = {-1};
|
||||
int len;
|
||||
#endif
|
||||
|
||||
if ((!temperature_config->sensor_type) || (!temperature_config->sensor_name))
|
||||
{
|
||||
if (temperature_config->sensor_name) evas_stringshare_del(temperature_config->sensor_name);
|
||||
if (temperature_config->sensor_path) evas_stringshare_del(temperature_config->sensor_path);
|
||||
temperature_config->sensor_path = NULL;
|
||||
#ifdef __FreeBSD__
|
||||
if (mib[0] == -1)
|
||||
{
|
||||
len = 5;
|
||||
sysctlnametomib("hw.acpi.thermal.tz0.temperature", mib, &len);
|
||||
}
|
||||
|
||||
if (mib[0] != -1)
|
||||
{
|
||||
len = sizeof(temp);
|
||||
if (sysctl(mib, 5, &temp, &len, NULL, 0) != -1)
|
||||
{
|
||||
temp = (temp - 2732) / 10;
|
||||
ret = 1;
|
||||
}
|
||||
}
|
||||
/* TODO: FreeBSD can also have more temperature sensors! */
|
||||
temperature_config->sensor_type = SENSOR_TYPE_FREEBSD;
|
||||
temperature_config->sensor_name = evas_stringshare_add("tz0");
|
||||
#else
|
||||
# ifdef HAVE_OMNIBOOK
|
||||
FILE *f;
|
||||
char dummy[256];
|
||||
|
||||
f = fopen("/proc/omnibook/temperature", "r");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3)
|
||||
ret = 1;
|
||||
fclose(f);
|
||||
}
|
||||
/* TODO: This does not have to be a define */
|
||||
temperature_config->sensor_type = SENSOR_TYPE_OMNIBOOK;
|
||||
temperature_config->sensor_name = evas_stringshare_add("dummy");
|
||||
# else
|
||||
therms = ecore_file_ls("/proc/acpi/thermal_zone");
|
||||
if ((!therms) || ecore_list_is_empty(therms))
|
||||
if ((therms) && (!ecore_list_is_empty(therms)))
|
||||
{
|
||||
char *name;
|
||||
|
||||
name = ecore_list_next(therms);
|
||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_ACPI;
|
||||
temperature_config->sensor_name = evas_stringshare_add(name);
|
||||
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
else
|
||||
{
|
||||
FILE *f;
|
||||
|
||||
|
@ -223,32 +214,163 @@ _temperature_cb_check(void *data)
|
|||
f = fopen("/sys/devices/temperatures/cpu_temperature", "rb");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
if (sscanf(buf, "%i", &temp) == 1)
|
||||
ret = 1;
|
||||
fclose(f);
|
||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_MACMINI;
|
||||
temperature_config->sensor_name = evas_stringshare_add("dummy");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO: Is there I2C devices with more than 3 temperature sensors? */
|
||||
/* TODO: What to do when there is more than one tempX? */
|
||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||
if (therms)
|
||||
{
|
||||
const char *name, *sensor;
|
||||
|
||||
sensor = temperature_config->sensor_name;
|
||||
if (!sensor) sensor = "temp1";
|
||||
char *name;
|
||||
|
||||
while ((name = ecore_list_next(therms)))
|
||||
{
|
||||
char fname[1024];
|
||||
char *sensors[] = { "temp1", "temp2", "temp3" };
|
||||
int i;
|
||||
|
||||
sprintf(fname, "/sys/bus/i2c/devices/%s/%s_input",
|
||||
name, sensor);
|
||||
if (ecore_file_exists(fname))
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
|
||||
name, sensors[i]);
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
temperature_config->sensor_type = SENSOR_TYPE_LINUX_I2C;
|
||||
temperature_config->sensor_name = evas_stringshare_add(sensors[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (temperature_config->sensor_type) break;
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
if ((temperature_config->sensor_type) &&
|
||||
(temperature_config->sensor_name) &&
|
||||
(!temperature_config->sensor_path))
|
||||
{
|
||||
switch (temperature_config->sensor_type)
|
||||
{
|
||||
case SENSOR_TYPE_NONE:
|
||||
break;
|
||||
case SENSOR_TYPE_FREEBSD:
|
||||
#ifdef __FreeBSD__
|
||||
snprintf(path, sizeof(path), "hw.acpi.thermal.%s.temperature",
|
||||
temperature_config->sensor_name);
|
||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
||||
|
||||
len = 5;
|
||||
sysctlnametomib(temperature_config->sensor_path, temperature_config->mib, &len);
|
||||
#endif
|
||||
break;
|
||||
case SENSOR_TYPE_OMNIBOOK:
|
||||
temperature_config->sensor_path = evas_stringshare_add("/proc/omnibook/temperature");
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_MACMINI:
|
||||
temperature_config->sensor_path = evas_stringshare_add("/sys/devices/temperatures/cpu_temperature");
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_I2C:
|
||||
therms = ecore_file_ls("/sys/bus/i2c/devices");
|
||||
if (therms)
|
||||
{
|
||||
char *name;
|
||||
|
||||
while ((name = ecore_list_next(therms)))
|
||||
{
|
||||
sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
|
||||
name, temperature_config->sensor_name);
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_ACPI:
|
||||
snprintf(path, sizeof(path), "/proc/acpi/thermal_zone/%s/temperature",
|
||||
temperature_config->sensor_name);
|
||||
temperature_config->sensor_path = evas_stringshare_add(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
_temperature_cb_check(void *data)
|
||||
{
|
||||
FILE *f;
|
||||
int ret = 0;
|
||||
Instance *inst;
|
||||
Evas_List *l;
|
||||
int temp = 0;
|
||||
char buf[4096];
|
||||
#ifdef __FreeBSD__
|
||||
int len;
|
||||
#endif
|
||||
|
||||
f = fopen(fname,"r");
|
||||
_temperature_sensor_init();
|
||||
|
||||
/* TODO: Make standard parser. Seems to be two types of temperature string:
|
||||
* - Somename: <temp> C
|
||||
* - <temp>
|
||||
*/
|
||||
switch (temperature_config->sensor_type)
|
||||
{
|
||||
case SENSOR_TYPE_NONE:
|
||||
/* TODO: Slow down timer? */
|
||||
break;
|
||||
case SENSOR_TYPE_FREEBSD:
|
||||
#ifdef __FreeBSD__
|
||||
len = sizeof(temp);
|
||||
if (sysctl(mib, 5, &temp, &len, NULL, 0) != -1)
|
||||
{
|
||||
temp = (temp - 2732) / 10;
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
#endif
|
||||
break;
|
||||
case SENSOR_TYPE_OMNIBOOK:
|
||||
f = fopen(temperature_config->sensor_path, "r");
|
||||
if (f)
|
||||
{
|
||||
char dummy[4096];
|
||||
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
if (sscanf(buf, "%s %s %i", dummy, dummy, &temp) == 3)
|
||||
ret = 1;
|
||||
else
|
||||
goto error;
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_MACMINI:
|
||||
f = fopen(temperature_config->sensor_path, "rb");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
if (sscanf(buf, "%i", &temp) == 1)
|
||||
ret = 1;
|
||||
else
|
||||
goto error;
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_I2C:
|
||||
f = fopen(temperature_config->sensor_path, "r");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f);
|
||||
|
@ -257,31 +379,20 @@ _temperature_cb_check(void *data)
|
|||
/* actuallty read the temp */
|
||||
if (sscanf(buf, "%i", &temp) == 1)
|
||||
ret = 1;
|
||||
else
|
||||
goto error;
|
||||
/* Hack for temp */
|
||||
temp = temp / 1000;
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *name;
|
||||
|
||||
ret = 0;
|
||||
name = temperature_config->acpi_sel;
|
||||
if (!name) name = ecore_list_next(therms);
|
||||
if (name)
|
||||
{
|
||||
char *p, *q;
|
||||
FILE *f;
|
||||
snprintf(buf, sizeof(buf), "/proc/acpi/thermal_zone/%s/temperature", name);
|
||||
f = fopen(buf, "rb");
|
||||
goto error;
|
||||
break;
|
||||
case SENSOR_TYPE_LINUX_ACPI:
|
||||
f = fopen(temperature_config->sensor_path, "r");
|
||||
if (f)
|
||||
{
|
||||
char *p, *q;
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
fclose(f);
|
||||
p = strchr(buf, ':');
|
||||
|
@ -294,12 +405,13 @@ _temperature_cb_check(void *data)
|
|||
temp = atoi(p);
|
||||
ret = 1;
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
break;
|
||||
}
|
||||
ecore_list_destroy(therms);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (temperature_config->units == FAHRENHEIT)
|
||||
temp = (temp * 9.0 / 5.0) + 32;
|
||||
|
@ -351,6 +463,17 @@ _temperature_cb_check(void *data)
|
|||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
error:
|
||||
/* TODO: Error count? Might be a temporary problem */
|
||||
/* TODO: Error dialog */
|
||||
/* TODO: This should be further up, so that it will affect the gadcon */
|
||||
temperature_config->sensor_type = SENSOR_TYPE_NONE;
|
||||
if (temperature_config->sensor_name) evas_stringshare_del(temperature_config->sensor_name);
|
||||
temperature_config->sensor_name = NULL;
|
||||
if (temperature_config->sensor_path) evas_stringshare_del(temperature_config->sensor_path);
|
||||
temperature_config->sensor_path = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -377,8 +500,7 @@ _temperature_face_cb_config_updated(void)
|
|||
{
|
||||
ecore_timer_del(temperature_config->temperature_check_timer);
|
||||
temperature_config->temperature_check_timer =
|
||||
ecore_timer_add(temperature_config->poll_time, _temperature_cb_check,
|
||||
NULL);
|
||||
ecore_timer_add(temperature_config->poll_time, _temperature_cb_check, NULL);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
@ -401,9 +523,9 @@ e_modapi_init(E_Module *m)
|
|||
E_CONFIG_VAL(D, T, poll_time, DOUBLE);
|
||||
E_CONFIG_VAL(D, T, low, INT);
|
||||
E_CONFIG_VAL(D, T, high, INT);
|
||||
E_CONFIG_VAL(D, T, sensor_type, INT);
|
||||
E_CONFIG_VAL(D, T, sensor_name, STR);
|
||||
E_CONFIG_VAL(D, T, units, INT);
|
||||
E_CONFIG_VAL(D, T, acpi_sel, STR);
|
||||
|
||||
temperature_config = e_config_domain_load("module.temperature", conf_edd);
|
||||
if (!temperature_config)
|
||||
|
@ -412,9 +534,10 @@ e_modapi_init(E_Module *m)
|
|||
temperature_config->poll_time = 10.0;
|
||||
temperature_config->low = 30;
|
||||
temperature_config->high = 80;
|
||||
temperature_config->sensor_name = evas_stringshare_add("temp1");
|
||||
temperature_config->sensor_type = SENSOR_TYPE_NONE;
|
||||
temperature_config->sensor_name = NULL;
|
||||
temperature_config->sensor_path = NULL;
|
||||
temperature_config->units = CELCIUS;
|
||||
temperature_config->acpi_sel = NULL;
|
||||
}
|
||||
E_CONFIG_LIMIT(temperature_config->poll_time, 0.5, 1000.0);
|
||||
E_CONFIG_LIMIT(temperature_config->low, 0, 100);
|
||||
|
@ -449,6 +572,8 @@ e_modapi_shutdown(E_Module *m)
|
|||
ecore_timer_del(temperature_config->temperature_check_timer);
|
||||
if (temperature_config->sensor_name)
|
||||
evas_stringshare_del(temperature_config->sensor_name);
|
||||
if (temperature_config->sensor_path)
|
||||
evas_stringshare_del(temperature_config->sensor_path);
|
||||
free(temperature_config);
|
||||
temperature_config = NULL;
|
||||
E_CONFIG_DD_FREE(conf_edd);
|
||||
|
|
|
@ -12,13 +12,24 @@ typedef enum _Unit
|
|||
FAHRENHEIT
|
||||
} Unit;
|
||||
|
||||
typedef enum _Sensor_Type
|
||||
{
|
||||
SENSOR_TYPE_NONE,
|
||||
SENSOR_TYPE_FREEBSD,
|
||||
SENSOR_TYPE_OMNIBOOK,
|
||||
SENSOR_TYPE_LINUX_MACMINI,
|
||||
SENSOR_TYPE_LINUX_I2C,
|
||||
SENSOR_TYPE_LINUX_ACPI
|
||||
} Sensor_Type;
|
||||
|
||||
struct _Config
|
||||
{
|
||||
/* saved * loaded config values */
|
||||
double poll_time;
|
||||
int low, high;
|
||||
Sensor_Type sensor_type;
|
||||
const char *sensor_name;
|
||||
const char *acpi_sel;
|
||||
const char *sensor_path;
|
||||
Unit units;
|
||||
/* just config state */
|
||||
E_Module *module;
|
||||
|
@ -27,6 +38,9 @@ struct _Config
|
|||
E_Menu *menu;
|
||||
Ecore_Timer *temperature_check_timer;
|
||||
unsigned char have_temp;
|
||||
#ifdef __FreeBSD__
|
||||
int mib[5];
|
||||
#endif
|
||||
};
|
||||
|
||||
EAPI extern E_Module_Api e_modapi;
|
||||
|
|
Loading…
Reference in New Issue