From 60131f4f0beb43ddb501a0ff114030c9c5f28b7d Mon Sep 17 00:00:00 2001 From: Leandro Pereira Date: Tue, 4 Jul 2017 13:47:47 -0700 Subject: Use load graph (used in memory view) to graph sensor data Writing this I realized why I stopped working on HardInfo. While there are some good ideas in the architecture, it's API is beyond salvation. It's buggy, quirky, and not intuitive at all. --- modules/devices/sensors.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'modules/devices/sensors.c') diff --git a/modules/devices/sensors.c b/modules/devices/sensors.c index 8c33feb3..c9d78ff7 100644 --- a/modules/devices/sensors.c +++ b/modules/devices/sensors.c @@ -131,10 +131,15 @@ static void add_sensor(const char *type, const char *driver, double value, const char *unit) { - static int count = 0; + char key[64]; - sensors = h_strdup_cprintf("%s#%d=%s|%s|%.2f%s\n", - sensors, type, count++, driver, sensor, value, unit); + sensors = h_strdup_cprintf("%s/%s=%.2f%s|%s\n", sensors, + driver, sensor, value, unit, type); + + snprintf(key, sizeof(key), "%s/%s", driver, sensor); + moreinfo_add_with_prefix("DEV", key, g_strdup_printf("%.2f%s", value, unit)); + + lginterval = h_strdup_cprintf("UpdateInterval$%s=1000\n", lginterval, key); } static gchar *get_sensor_label(gchar *sensor) { @@ -348,7 +353,7 @@ static void read_sensors_sys_thermal(void) { add_sensor("Temperature", entry, - "thermal_zone", + "thermal", temperature / 1000.0, "\302\260C"); @@ -423,15 +428,16 @@ static void read_sensors_hddtemp(void) { void scan_sensors_do(void) { g_free(sensors); - sensors = g_strdup(""); + g_free(lginterval); + lginterval = g_strdup(""); + read_sensors_hwmon(); read_sensors_acpi(); read_sensors_sys_thermal(); read_sensors_omnibook(); read_sensors_hddtemp(); - /* FIXME: Add support for ibm acpi and more sensors */ } -- cgit v1.2.3