openbsd et al. Support as many sensors we can find.
This isn't finished, build broken for Linux and others.
This commit is contained in:
parent
384030bade
commit
dcf23687a3
|
@ -638,36 +638,41 @@ swap_out:
|
|||
}
|
||||
|
||||
static void
|
||||
_thermal_zone_temp_get(float *temperature)
|
||||
_sensors_thermal_get(Sys_Info *sysinfo)
|
||||
{
|
||||
sensor_t **sensors = sysinfo->sensors;
|
||||
#if defined(__OpenBSD__) || defined(__NetBSD__)
|
||||
int mibs[5] = { CTL_HW, HW_SENSORS, 0, 0, 0 };
|
||||
int devn, numt;
|
||||
int devn, n;
|
||||
struct sensor snsr;
|
||||
size_t slen = sizeof(struct sensor);
|
||||
struct sensordev snsrdev;
|
||||
size_t sdlen = sizeof(struct sensordev);
|
||||
sensor_t *sensor;
|
||||
|
||||
for (devn = 0;; devn++) {
|
||||
for (devn = 0;; devn++)
|
||||
{
|
||||
mibs[2] = devn;
|
||||
|
||||
if (sysctl(mibs, 3, &snsrdev, &sdlen, NULL, 0) == -1)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
break;
|
||||
else
|
||||
if (errno == ENOENT) break;
|
||||
continue;
|
||||
}
|
||||
if (!strcmp("cpu0", snsrdev.xname))
|
||||
break;
|
||||
else if (!strcmp("km0", snsrdev.xname))
|
||||
break;
|
||||
else if (!strncmp("bcmt", snsrdev.xname, 4))
|
||||
break;
|
||||
|
||||
if ((strcmp("cpu0", snsrdev.xname)) && (strcmp("kmo", snsrdev.xname)) &&
|
||||
(strcmp("acpitz0", snsrdev.xname)) && (strncmp("bcmt", snsrdev.xname, 4)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (numt = 0; numt < snsrdev.maxnumt[SENSOR_TEMP]; numt++) {
|
||||
mibs[4] = numt;
|
||||
sensors = realloc(sensors, 1 + sysinfo->snsr_count * sizeof(sensor_t *));
|
||||
sensors[sysinfo->snsr_count++] = sensor = calloc(1, sizeof(sensor_t));
|
||||
sensor->name = strdup(snsrdev.xname);
|
||||
|
||||
for (n = 0; n < snsrdev.maxnumt[SENSOR_TEMP]; n++)
|
||||
{
|
||||
mibs[4] = n;
|
||||
|
||||
if (sysctl(mibs, 5, &snsr, &slen, NULL, 0) == -1)
|
||||
continue;
|
||||
|
@ -676,13 +681,11 @@ _thermal_zone_temp_get(float *temperature)
|
|||
break;
|
||||
}
|
||||
|
||||
if (sysctl(mibs, 5, &snsr, &slen, NULL, 0)
|
||||
!= -1)
|
||||
{
|
||||
*temperature = (snsr.value - 273150000) / 1000000.0;
|
||||
}
|
||||
if (sysctl(mibs, 5, &snsr, &slen, NULL, 0) != -1)
|
||||
sensor->value = (snsr.value - 273150000) / 1000000.0;
|
||||
else
|
||||
*temperature = INVALID_TEMP;
|
||||
sensor->invalid = true;
|
||||
}
|
||||
#elif defined(__FreeBSD__) || defined(__DragonFly__)
|
||||
unsigned int value;
|
||||
size_t len = sizeof(value);
|
||||
|
@ -735,6 +738,7 @@ _thermal_zone_temp_get(float *temperature)
|
|||
#elif defined(__MacOS__)
|
||||
*temperature = INVALID_TEMP;
|
||||
#endif
|
||||
sysinfo->sensors = sensors;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1176,16 +1180,6 @@ _results_cpu(cpu_core_t **cores, int cpu_count)
|
|||
return total;
|
||||
}
|
||||
|
||||
float
|
||||
system_thermal_zone_temp_get(void)
|
||||
{
|
||||
float temp;
|
||||
|
||||
_thermal_zone_temp_get(&temp);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
void
|
||||
system_power_state_get(power_t *power)
|
||||
{
|
||||
|
@ -1276,7 +1270,7 @@ sys_info_all_get(void)
|
|||
if (_power_battery_count_get(&results->power))
|
||||
_power_state_get(&results->power);
|
||||
|
||||
_thermal_zone_temp_get(&results->temperature);
|
||||
_sensors_thermal_get(results);
|
||||
|
||||
if (!error)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,13 @@ typedef struct
|
|||
unsigned long long zfs_arc_used;
|
||||
} meminfo_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *name;
|
||||
double value;
|
||||
bool invalid;
|
||||
} sensor_t;
|
||||
|
||||
#define MAX_BATTERIES 10
|
||||
|
||||
typedef struct
|
||||
|
@ -54,14 +61,14 @@ struct Sys_Info
|
|||
{
|
||||
int cpu_count;
|
||||
cpu_core_t **cores;
|
||||
|
||||
meminfo_t memory;
|
||||
|
||||
power_t power;
|
||||
|
||||
int snsr_count;
|
||||
sensor_t **sensors;
|
||||
|
||||
unsigned long incoming;
|
||||
unsigned long outgoing;
|
||||
float temperature;
|
||||
};
|
||||
|
||||
Sys_Info *
|
||||
|
|
|
@ -100,7 +100,6 @@ typedef struct Ui
|
|||
|
||||
Eina_List *cpu_times;
|
||||
Eina_List *cpu_list;
|
||||
Evas_Object *temp_label;
|
||||
|
||||
int poll_delay;
|
||||
|
||||
|
|
|
@ -56,12 +56,6 @@ ui_tab_cpu_add(Ui *ui)
|
|||
evas_object_show(label);
|
||||
elm_box_pack_end(box, label);
|
||||
|
||||
ui->temp_label = label = elm_label_add(box);
|
||||
evas_object_size_hint_align_set(label, FILL, 0);
|
||||
evas_object_size_hint_weight_set(label, EXPAND, EXPAND);
|
||||
evas_object_show(label);
|
||||
elm_box_pack_end(box, label);
|
||||
|
||||
cpu_count = system_cpu_online_count_get();
|
||||
for (int i = 0; i < cpu_count; i++)
|
||||
{
|
||||
|
@ -98,11 +92,6 @@ ui_tab_cpu_update(Ui *ui, Sys_Info *sysinfo)
|
|||
if (!ui->cpu_visible)
|
||||
return;
|
||||
|
||||
if (sysinfo->temperature != INVALID_TEMP)
|
||||
elm_object_text_set(ui->temp_label,
|
||||
eina_slstr_printf(_("Thermal Zone: %1.1f°C"),
|
||||
sysinfo->temperature));
|
||||
|
||||
EINA_LIST_FOREACH(ui->cpu_list, l, pb)
|
||||
{
|
||||
elm_progressbar_value_set(pb, sysinfo->cores[i]->percent / 100);
|
||||
|
|
|
@ -77,6 +77,23 @@ _battery_usage_add(Evas_Object *box, power_t *power)
|
|||
free(power->batteries);
|
||||
}
|
||||
|
||||
static void
|
||||
_sensor_usage_add(Evas_Object *box, Sys_Info *sysinfo)
|
||||
{
|
||||
sensor_t *snsr;
|
||||
|
||||
for (int i = 0; i < sysinfo->snsr_count; i++)
|
||||
{
|
||||
snsr = sysinfo->sensors[i];
|
||||
printf("%s => %1.2f\n", snsr->name, snsr->value);
|
||||
if (snsr->name)
|
||||
free(snsr->name);
|
||||
free(snsr);
|
||||
}
|
||||
if (sysinfo->sensors)
|
||||
free(sysinfo->sensors);
|
||||
}
|
||||
|
||||
static char *
|
||||
_network_transfer_format(double rate)
|
||||
{
|
||||
|
@ -219,6 +236,7 @@ ui_tab_misc_update(Ui *ui, Sys_Info *sysinfo)
|
|||
evas_object_show(box);
|
||||
|
||||
_battery_usage_add(box, &sysinfo->power);
|
||||
_sensor_usage_add(box, sysinfo);
|
||||
_network_usage_add(ui, box, sysinfo->incoming, EINA_TRUE);
|
||||
_network_usage_add(ui, box, sysinfo->outgoing, EINA_FALSE);
|
||||
|
||||
|
|
Loading…
Reference in New Issue