diff options
-rw-r--r-- | includes/devices.h | 1 | ||||
-rw-r--r-- | modules/devices.c | 4 | ||||
-rw-r--r-- | modules/devices/sensors.c | 48 |
3 files changed, 39 insertions, 14 deletions
diff --git a/includes/devices.h b/includes/devices.h index 03d4587b..ebb7a01a 100644 --- a/includes/devices.h +++ b/includes/devices.h @@ -74,6 +74,7 @@ extern gchar *pci_list; extern gchar *printer_icons; extern gchar *printer_list; extern gchar *sensors; +extern gchar *sensor_icons; extern gchar *storage_icons; extern gchar *storage_list; extern gchar *usb_list; diff --git a/modules/devices.c b/modules/devices.c index 31c1bdfc..5b2ecb40 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -759,10 +759,12 @@ gchar *callback_sensors() "ColumnTitle$Extra1=%s\n" "ShowColumnHeaders=true\n" "RescanInterval=5000\n" + "%s\n" "%s", sensors, _("Sensor"), _("Value"), _("Type"), /* column labels */ - lginterval); + lginterval, + sensor_icons); } gchar *callback_printers() diff --git a/modules/devices/sensors.c b/modules/devices/sensors.c index 21206075..d660ef92 100644 --- a/modules/devices/sensors.c +++ b/modules/devices/sensors.c @@ -25,6 +25,7 @@ #include "udisks2_util.h" gchar *sensors = NULL; +gchar *sensor_icons = NULL; GHashTable *sensor_compute = NULL; GHashTable *sensor_labels = NULL; gboolean hwmon_first_run = TRUE; @@ -131,13 +132,19 @@ static void add_sensor(const char *type, const char *sensor, const char *parent, double value, - const char *unit) { + const char *unit, + const char *icon) { char key[64]; snprintf(key, sizeof(key), "%s/%s", parent, sensor); sensors = h_strdup_cprintf("$%s$%s=%.2f%s|%s\n", sensors, key, sensor, value, unit, type); + if (icon != NULL) { + sensor_icons = h_strdup_cprintf("Icon$%s$%s=%s.png\n", sensor_icons, + key, sensor, icon); + } + moreinfo_add_with_prefix("DEV", key, g_strdup_printf("%.2f%s", value, unit)); lginterval = h_strdup_cprintf("UpdateInterval$%s=1000\n", lginterval, key); @@ -206,6 +213,7 @@ struct HwmonSensor { const char *key_format; const char *unit; const float adjust_ratio; + const char *icon; }; static const struct HwmonSensor hwmon_sensors[] = { @@ -216,7 +224,8 @@ static const struct HwmonSensor hwmon_sensors[] = { "%s/fan%d_label", "fan%d", "RPM", - 1.0 + 1.0, + "fan" }, { "Temperature", @@ -225,7 +234,8 @@ static const struct HwmonSensor hwmon_sensors[] = { "%s/temp%d_label", "temp%d", "\302\260C", - 1000.0 + 1000.0, + "therm" }, { "Voltage", @@ -234,7 +244,8 @@ static const struct HwmonSensor hwmon_sensors[] = { "%s/in%d_label", "in%d", "V", - 1000.0 + 1000.0, + "bolt" }, { "Current", @@ -243,7 +254,8 @@ static const struct HwmonSensor hwmon_sensors[] = { "%s/curr%d_label", "curr%d", "A", - 1000.0 + 1000.0, + "bolt" }, { "Power", @@ -252,7 +264,8 @@ static const struct HwmonSensor hwmon_sensors[] = { "%s/power%d_label", "power%d", "W", - 1000000.0 + 1000000.0, + "bolt" }, { "Voltage", @@ -261,7 +274,8 @@ static const struct HwmonSensor hwmon_sensors[] = { NULL, "cpu%d_vid", "V", - 1000.0 + 1000.0, + "bolt" }, { } }; @@ -372,7 +386,8 @@ static void read_sensors_hwmon(void) { name, devname, adjusted, - sensor->unit); + sensor->unit, + sensor->icon); } g_free(tmp); @@ -422,7 +437,8 @@ static void read_sensors_acpi(void) { entry, "ACPI Thermal Zone", temperature, - "\302\260C"); + "\302\260C", + "therm"); } } @@ -460,7 +476,8 @@ static void read_sensors_sys_thermal(void) { entry, "thermal", temperature / 1000.0, - "\302\260C"); + "\302\260C", + "therm"); g_free(contents); } @@ -486,7 +503,8 @@ static void read_sensors_omnibook(void) { "CPU", "omnibook", temperature, - "\302\260C"); + "\302\260C", + "therm"); g_free(contents); } @@ -526,7 +544,8 @@ static void read_sensors_hddtemp(void) { fields[1], "hddtemp", atoi(fields[2]), - unit); + unit, + "therm"); g_strfreev(fields); } @@ -552,7 +571,8 @@ void read_sensors_udisks2(void) { disk->drive, "udisks2", disk->temperature, - "\302\260C"); + "\302\260C", + "therm"); udiskt_free(disk); } g_slist_free(temps); @@ -560,7 +580,9 @@ void read_sensors_udisks2(void) { void scan_sensors_do(void) { g_free(sensors); + g_free(sensor_icons); sensors = g_strdup(""); + sensor_icons = g_strdup(""); g_free(lginterval); lginterval = g_strdup(""); |