summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/pmu-sys/pmu-sys-plugin.c225
-rw-r--r--plugins/smu-sys/smu-sys-plugin.c224
-rw-r--r--plugins/sonypi/sonypi-plugin.c96
-rw-r--r--plugins/udisks/udisks-plugin.c528
-rw-r--r--plugins/udisks2/udisks2-plugin.c573
5 files changed, 802 insertions, 844 deletions
diff --git a/plugins/pmu-sys/pmu-sys-plugin.c b/plugins/pmu-sys/pmu-sys-plugin.c
index c269360..8a3821b 100644
--- a/plugins/pmu-sys/pmu-sys-plugin.c
+++ b/plugins/pmu-sys/pmu-sys-plugin.c
@@ -42,148 +42,151 @@ const gchar *plugin_name = "pmu-sys";
#define FAN_SPEED "_fan_speed"
-
enum {
- PMU_SYS_DEVICE_FILE_OPEN_ERROR,
- PMU_SYS_DEVICE_FILE_READ_ERROR
+ PMU_SYS_DEVICE_FILE_OPEN_ERROR,
+ PMU_SYS_DEVICE_FILE_READ_ERROR
};
static void pmu_sys_plugin_add_sensor(GList **sensors, const gchar *path) {
- gchar *filename;
- gchar *label = NULL;
- gboolean enable;
- SensorType sensor_type;
- IconType icon_type = GENERIC_ICON;
-
- filename = g_path_get_basename(path);
-
- if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
- label = g_strdup(_("CPU"));
- sensor_type = TEMP_SENSOR;
- enable = TRUE;
- icon_type = CPU_ICON;
- } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
- label = g_strdup(_("GPU"));
- sensor_type = TEMP_SENSOR;
- enable = TRUE;
- icon_type = GPU_ICON;
- } else if (g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0) {
- label = g_strdup(_("CASE"));
- sensor_type = TEMP_SENSOR;
- enable = TRUE;
- icon_type = CASE_ICON;
- } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
- label = g_strdup(_("FAN"));
- sensor_type = FAN_SENSOR;
- enable = TRUE;
- icon_type = FAN_ICON;
- } else {
- /* disable all other sensors */
- enable = FALSE;
- }
-
- /* only add these 3 sensors */
- if (enable) {
- sensors_applet_plugin_add_sensor(sensors,
- path,
- filename,
- label,
- sensor_type,
- enable,
- icon_type,
- DEFAULT_GRAPH_COLOR);
-
- }
- g_free(filename);
- if (label != NULL) {
- g_free(label);
- }
-}
+ gchar *filename;
+ gchar *label = NULL;
+ gboolean enable;
+ SensorType sensor_type;
+ IconType icon_type = GENERIC_ICON;
+
+ filename = g_path_get_basename(path);
+
+ if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
+ label = g_strdup(_("CPU"));
+ sensor_type = TEMP_SENSOR;
+ enable = TRUE;
+ icon_type = CPU_ICON;
+ } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
+ label = g_strdup(_("GPU"));
+ sensor_type = TEMP_SENSOR;
+ enable = TRUE;
+ icon_type = GPU_ICON;
+ } else if (g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0) {
+ label = g_strdup(_("CASE"));
+ sensor_type = TEMP_SENSOR;
+ enable = TRUE;
+ icon_type = CASE_ICON;
+ } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+ label = g_strdup(_("FAN"));
+ sensor_type = FAN_SENSOR;
+ enable = TRUE;
+ icon_type = FAN_ICON;
+ } else {
+ /* disable all other sensors */
+ enable = FALSE;
+ }
+
+ /* only add these 3 sensors */
+ if (enable) {
+ sensors_applet_plugin_add_sensor(sensors,
+ path,
+ filename,
+ label,
+ sensor_type,
+ enable,
+ icon_type,
+ DEFAULT_GRAPH_COLOR);
+
+ }
+
+ g_free(filename);
+ if (label != NULL) {
+ g_free(label);
+ }
+}
static void pmu_sys_plugin_test_sensor(GList **sensors, const gchar *path) {
- gchar *filename;
- filename = g_path_get_basename(path);
- if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
- g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
- pmu_sys_plugin_add_sensor(sensors, path);
- }
- g_free(filename);
-
+ gchar *filename;
+ filename = g_path_get_basename(path);
+ if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
+ g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+
+ pmu_sys_plugin_add_sensor(sensors, path);
+ }
+
+ g_free(filename);
}
+
/* to be called to setup for sys sensors */
GList *pmu_sys_plugin_init(void) {
- GList *sensors = NULL;
- /* call function to recursively look for sensors
- starting at the defined base directory */
- sensors_applet_plugin_find_sensors(&sensors, PMU_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
- sensors_applet_plugin_find_sensors(&sensors, PMU_WT_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
- return sensors;
+ GList *sensors = NULL;
+ /* call function to recursively look for sensors
+ starting at the defined base directory */
+ sensors_applet_plugin_find_sensors(&sensors, PMU_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
+ sensors_applet_plugin_find_sensors(&sensors, PMU_WT_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
+ return sensors;
}
/* returns the value of the sensor_list at the given iter, or if an
error occurs, instatiates error with an error message */
-gdouble pmu_sys_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+gdouble pmu_sys_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error) {
- /* to open and access the value of each sensor */
- FILE *fp;
- gfloat sensor_value, dummy;
-
- if (NULL == (fp = fopen(path, "r"))) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+ /* to open and access the value of each sensor */
+ FILE *fp;
+ gfloat sensor_value, dummy;
+
+ if (NULL == (fp = fopen(path, "r"))) {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+ return -1.0;
+ }
+ switch(type) {
+ case FAN_SENSOR:
+ if (fscanf(fp, "%f (%f rpm)", &dummy, &sensor_value) != 2) {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+ fclose(fp);
return -1.0;
- }
- switch(type) {
- case FAN_SENSOR:
- if (fscanf(fp, "%f (%f rpm)", &dummy, &sensor_value) != 2) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- fclose(fp);
- return -1.0;
- }
- break;
-
- case TEMP_SENSOR:
- if (fscanf(fp, "%f", &sensor_value) != 1) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- fclose(fp);
- return -1.0;
- }
- break;
-
- default:
- /* should only have added temp or fan sensors */
- g_error("Unknown sensor type passed as parameter to pmu-sys sensor interface, cannot get value for this sensor");
+ }
+ break;
+
+ case TEMP_SENSOR:
+ if (fscanf(fp, "%f", &sensor_value) != 1) {
g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
fclose(fp);
return -1.0;
+ }
+ break;
- }
- fclose(fp);
+ default:
+ /* should only have added temp or fan sensors */
+ g_error("Unknown sensor type passed as parameter to pmu-sys sensor interface, cannot get value for this sensor");
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+ fclose(fp);
+ return -1.0;
- return (gdouble)sensor_value;
+ }
+ fclose(fp);
+
+ return (gdouble)sensor_value;
}
-const gchar *sensors_applet_plugin_name(void)
+const gchar *sensors_applet_plugin_name(void)
{
- return plugin_name;
+ return plugin_name;
}
-GList *sensors_applet_plugin_init(void)
+GList *sensors_applet_plugin_init(void)
{
- return pmu_sys_plugin_init();
+ return pmu_sys_plugin_init();
}
-gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error) {
- return pmu_sys_plugin_get_sensor_value(path, id, type, error);
+
+ return pmu_sys_plugin_get_sensor_value(path, id, type, error);
}
diff --git a/plugins/smu-sys/smu-sys-plugin.c b/plugins/smu-sys/smu-sys-plugin.c
index f306be4..75f2b6a 100644
--- a/plugins/smu-sys/smu-sys-plugin.c
+++ b/plugins/smu-sys/smu-sys-plugin.c
@@ -41,140 +41,142 @@ const gchar *plugin_name = "smu-sys";
enum {
- SMU_SYS_DEVICE_FILE_OPEN_ERROR,
- SMU_SYS_DEVICE_FILE_READ_ERROR
+ SMU_SYS_DEVICE_FILE_OPEN_ERROR,
+ SMU_SYS_DEVICE_FILE_READ_ERROR
};
static void smu_sys_plugin_add_sensor(GList **sensors, const gchar *path) {
- gchar *filename;
- gchar *label = NULL;
- gboolean enable;
- SensorType sensor_type;
- IconType icon_type = GENERIC_ICON;
-
- filename = g_path_get_basename(path);
-
- if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
- label = g_strdup(_("CPU"));
- sensor_type = TEMP_SENSOR;
- enable = TRUE;
- icon_type = CPU_ICON;
- } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
- label = g_strdup(_("GPU"));
- sensor_type = TEMP_SENSOR;
- enable = TRUE;
- icon_type = GPU_ICON;
- } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
- label = g_strdup(_("FAN"));
- sensor_type = FAN_SENSOR;
- enable = TRUE;
- icon_type = FAN_ICON;
- } else {
- /* disable all other sensors */
- enable = FALSE;
- }
-
- /* only add these 3 sensors */
- if (enable) {
- sensors_applet_plugin_add_sensor(sensors,
- path,
- filename,
- label,
- sensor_type,
- enable,
- icon_type,
- DEFAULT_GRAPH_COLOR);
-
- }
- g_free(filename);
- if (label != NULL) {
- g_free(label);
- }
-}
+ gchar *filename;
+ gchar *label = NULL;
+ gboolean enable;
+ SensorType sensor_type;
+ IconType icon_type = GENERIC_ICON;
+
+ filename = g_path_get_basename(path);
+
+ if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
+ label = g_strdup(_("CPU"));
+ sensor_type = TEMP_SENSOR;
+ enable = TRUE;
+ icon_type = CPU_ICON;
+ } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
+ label = g_strdup(_("GPU"));
+ sensor_type = TEMP_SENSOR;
+ enable = TRUE;
+ icon_type = GPU_ICON;
+ } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+ label = g_strdup(_("FAN"));
+ sensor_type = FAN_SENSOR;
+ enable = TRUE;
+ icon_type = FAN_ICON;
+ } else {
+ /* disable all other sensors */
+ enable = FALSE;
+ }
+
+ /* only add these 3 sensors */
+ if (enable) {
+ sensors_applet_plugin_add_sensor(sensors,
+ path,
+ filename,
+ label,
+ sensor_type,
+ enable,
+ icon_type,
+ DEFAULT_GRAPH_COLOR);
+
+ }
+
+ g_free(filename);
+ if (label != NULL) {
+ g_free(label);
+ }
+}
static void smu_sys_plugin_test_sensor(GList **sensors, const gchar *path) {
- gchar *filename;
-
- filename = g_path_get_basename(path);
- if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
- g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
- g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
- smu_sys_plugin_add_sensor(sensors, path);
- }
- g_free(filename);
+ gchar *filename;
+
+ filename = g_path_get_basename(path);
+ if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
+ g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
+ g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+
+ smu_sys_plugin_add_sensor(sensors, path);
+ }
+ g_free(filename);
}
+
/* to be called to setup for sys sensors */
GList *smu_sys_plugin_init(void) {
- GList *sensors = NULL;
-
- /* call function to recursively look for sensors
- starting at the defined base directory */
- sensors_applet_plugin_find_sensors(&sensors,
- SMU_SYS_BASE_DIR,
- smu_sys_plugin_test_sensor);
-
- return sensors;
+ GList *sensors = NULL;
+
+ /* call function to recursively look for sensors
+ starting at the defined base directory */
+ sensors_applet_plugin_find_sensors(&sensors, SMU_SYS_BASE_DIR, smu_sys_plugin_test_sensor);
+
+ return sensors;
}
/* returns the value of the sensor_list at the given iter, or if an
error occurs, instatiates error with an error message */
-gdouble smu_sys_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
-
- /* to open and access the value of each sensor */
- FILE *fp;
- gfloat sensor_value = -1.0;
-
- if (NULL == (fp = fopen(path, "r"))) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
- return -1.0;
- }
- switch(type) {
- case FAN_SENSOR:
- if (fscanf(fp, "%f", &sensor_value) != 1) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- fclose(fp);
- return -1.0;
- }
- break;
-
- case TEMP_SENSOR:
- if (fscanf(fp, "%f", &sensor_value) != 1) {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- fclose(fp);
- return -1.0;
- }
- break;
-
- default:
- /* should only have added temp or fan sensors */
- g_error("Unknown sensor type passed as parameter to smu-sys sensor interface, cannot get value for this sensor");
+gdouble smu_sys_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+
+ /* to open and access the value of each sensor */
+ FILE *fp;
+ gfloat sensor_value = -1.0;
+
+ if (NULL == (fp = fopen(path, "r"))) {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+ return -1.0;
+ }
+ switch(type) {
+ case FAN_SENSOR:
+ if (fscanf(fp, "%f", &sensor_value) != 1) {
g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- }
- fclose(fp);
+ fclose(fp);
+ return -1.0;
+ }
+ break;
- return (gdouble)sensor_value;
+ case TEMP_SENSOR:
+ if (fscanf(fp, "%f", &sensor_value) != 1) {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+ fclose(fp);
+ return -1.0;
+ }
+ break;
+
+ default:
+ /* should only have added temp or fan sensors */
+ g_error("Unknown sensor type passed as parameter to smu-sys sensor interface, cannot get value for this sensor");
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+ }
+ fclose(fp);
+
+ return (gdouble)sensor_value;
}
-const gchar *sensors_applet_plugin_name(void)
+const gchar *sensors_applet_plugin_name(void)
{
- return plugin_name;
+ return plugin_name;
}
-GList *sensors_applet_plugin_init(void)
+GList *sensors_applet_plugin_init(void)
{
- return smu_sys_plugin_init();
+ return smu_sys_plugin_init();
}
-gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error) {
- return smu_sys_plugin_get_sensor_value(path, id, type, error);
+
+ return smu_sys_plugin_get_sensor_value(path, id, type, error);
}
diff --git a/plugins/sonypi/sonypi-plugin.c b/plugins/sonypi/sonypi-plugin.c
index 8dab2a7..ca5987a 100644
--- a/plugins/sonypi/sonypi-plugin.c
+++ b/plugins/sonypi/sonypi-plugin.c
@@ -45,69 +45,71 @@ const gchar *plugin_name = "sonypi";
#define SONYPI_TEMP "sonypi_temp"
enum {
- SONYPI_DEVICE_FILE_OPEN_ERROR,
- SONYPI_DEVICE_FILE_READ_ERROR
+ SONYPI_DEVICE_FILE_OPEN_ERROR,
+ SONYPI_DEVICE_FILE_READ_ERROR
};
GList *sonypi_plugin_init(void) {
- int fd;
- GList *sensors = NULL;
-
- if ( (fd = open(SONYPI_DEV, O_RDONLY)) != -1 ) {
- if ( close(fd) != -1 ) {
- sensors_applet_plugin_add_sensor(&sensors,
- SONYPI_DEV,
- SONYPI_TEMP,
- _("CPU TEMP"),
- TEMP_SENSOR,
- TRUE,
- CPU_ICON,
- DEFAULT_GRAPH_COLOR);
- }
+ int fd;
+ GList *sensors = NULL;
+
+ if ( (fd = open(SONYPI_DEV, O_RDONLY)) != -1 ) {
+ if ( close(fd) != -1 ) {
+ sensors_applet_plugin_add_sensor(&sensors,
+ SONYPI_DEV,
+ SONYPI_TEMP,
+ _("CPU TEMP"),
+ TEMP_SENSOR,
+ TRUE,
+ CPU_ICON,
+ DEFAULT_GRAPH_COLOR);
}
- return sensors;
+ }
+ return sensors;
}
-gdouble sonypi_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
- int fd;
- guint8 value8;
-
- gdouble sensor_value = -1.0;
-
- if ((fd = open(path, O_RDONLY)) != -1) {
- /* only use temp sensor */
- if (g_ascii_strcasecmp(id, SONYPI_TEMP) == 0) {
- if (ioctl(fd, SONYPI_IOCGTEMP, &value8) != -1) {
- sensor_value = (gdouble)value8;
- } else {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
- }
- }
- close(fd);
- } else {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_OPEN_ERROR, "Error opening from sensor device file %s", path);
+gdouble sonypi_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+
+ int fd;
+ guint8 value8;
+
+ gdouble sensor_value = -1.0;
+
+ if ((fd = open(path, O_RDONLY)) != -1) {
+ /* only use temp sensor */
+ if (g_ascii_strcasecmp(id, SONYPI_TEMP) == 0) {
+ if (ioctl(fd, SONYPI_IOCGTEMP, &value8) != -1) {
+ sensor_value = (gdouble)value8;
+ } else {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+ }
}
-
- return sensor_value;
+ close(fd);
+ } else {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_OPEN_ERROR, "Error opening from sensor device file %s", path);
+ }
+
+ return sensor_value;
}
-const gchar *sensors_applet_plugin_name(void)
+const gchar *sensors_applet_plugin_name(void)
{
- return plugin_name;
+ return plugin_name;
}
-GList *sensors_applet_plugin_init(void)
+GList *sensors_applet_plugin_init(void)
{
- return sonypi_plugin_init();
+ return sonypi_plugin_init();
}
-gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
GError **error) {
- return sonypi_plugin_get_sensor_value(path, id, type, error);
+
+ return sonypi_plugin_get_sensor_value(path, id, type, error);
}
diff --git a/plugins/udisks/udisks-plugin.c b/plugins/udisks/udisks-plugin.c
index 702de64..be259a4 100644
--- a/plugins/udisks/udisks-plugin.c
+++ b/plugins/udisks/udisks-plugin.c
@@ -1,6 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * vim: sts=0 sw=8 ts=8 tw=78 noexpandtab
- *
+/*
* Copyright (C) 2009 Pramod Dematagoda <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
@@ -39,11 +37,11 @@
* Info about a single sensor
*/
typedef struct _DevInfo{
- gchar *path;
- gchar *id;
- gdouble temp;
- DBusGProxy *sensor_proxy;
- GError *error;
+ gchar *path;
+ gchar *id;
+ gdouble temp;
+ DBusGProxy *sensor_proxy;
+ GError *error;
} DevInfo;
const gchar *plugin_name = "udisks";
@@ -55,296 +53,282 @@ DBusGConnection *connection;
static void update_device(DevInfo *info)
{
- DBusGProxy *sensor_proxy;
- GValue smart_time = { 0, };
- SkDisk *sk_disk;
- GValue smart_blob_val = { 0, };
- GArray *smart_blob;
- guint64 temperature;
-
- g_return_if_fail(info != NULL);
-
- g_clear_error(&info->error);
-
- sensor_proxy = dbus_g_proxy_new_for_name(connection,
- UDISKS_BUS_NAME,
- info->path,
- UDISKS_PROPERTIES_INTERFACE);
-
- if (!dbus_g_proxy_call(sensor_proxy, "Get", NULL,
- G_TYPE_STRING, UDISKS_BUS_NAME,
- G_TYPE_STRING, "DriveAtaSmartTimeCollected", G_TYPE_INVALID,
- G_TYPE_VALUE, &smart_time,
- G_TYPE_INVALID) ||
- !g_value_get_uint64(&smart_time))
- {
- g_object_unref(sensor_proxy);
- return;
- }
-
- if (!dbus_g_proxy_call(sensor_proxy, "Get", &info->error,
- G_TYPE_STRING, UDISKS_BUS_NAME,
- G_TYPE_STRING, "DriveAtaSmartBlob", G_TYPE_INVALID,
- G_TYPE_VALUE, &smart_blob_val,
- G_TYPE_INVALID))
- {
- g_debug("Error getting DriveAtaSmartBlob %s",
- info->error ? info->error->message : "NULL");
- g_object_unref(sensor_proxy);
- return;
- }
- smart_blob = g_value_get_boxed(&smart_blob_val);
-
- sk_disk_open(NULL, &sk_disk);
- sk_disk_set_blob(sk_disk, smart_blob->data, smart_blob->len);
- if (sk_disk_smart_get_temperature(sk_disk, &temperature) < 0)
- {
- g_debug("Error getting temperature from AtaSmartBlob");
- g_free(sk_disk);
- g_array_free(smart_blob, TRUE);
- g_object_unref(sensor_proxy);
- return;
- }
-
- /* Temperature is in mK, so convert it to K first */
- temperature /= 1000;
- info->temp = (gdouble)temperature - 273.15;
-
- g_free(sk_disk);
- g_array_free(smart_blob, TRUE);
- g_object_unref(sensor_proxy);
+ DBusGProxy *sensor_proxy;
+ GValue smart_time = { 0, };
+ SkDisk *sk_disk;
+ GValue smart_blob_val = { 0, };
+ GArray *smart_blob;
+ guint64 temperature;
+
+ g_return_if_fail(info != NULL);
+
+ g_clear_error(&info->error);
+
+ sensor_proxy = dbus_g_proxy_new_for_name(connection,
+ UDISKS_BUS_NAME,
+ info->path,
+ UDISKS_PROPERTIES_INTERFACE);
+
+ if (!dbus_g_proxy_call(sensor_proxy, "Get", NULL,
+ G_TYPE_STRING, UDISKS_BUS_NAME,
+ G_TYPE_STRING, "DriveAtaSmartTimeCollected", G_TYPE_INVALID,
+ G_TYPE_VALUE, &smart_time,
+ G_TYPE_INVALID) ||
+ !g_value_get_uint64(&smart_time)) {
+
+ g_object_unref(sensor_proxy);
+ return;
+ }
+
+ if (!dbus_g_proxy_call(sensor_proxy, "Get", &info->error,
+ G_TYPE_STRING, UDISKS_BUS_NAME,
+ G_TYPE_STRING, "DriveAtaSmartBlob", G_TYPE_INVALID,
+ G_TYPE_VALUE, &smart_blob_val,
+ G_TYPE_INVALID)) {
+
+ g_debug("Error getting DriveAtaSmartBlob %s", info->error ? info->error->message : "NULL");
+ g_object_unref(sensor_proxy);
+ return;
+ }
+ smart_blob = g_value_get_boxed(&smart_blob_val);
+
+ sk_disk_open(NULL, &sk_disk);
+ sk_disk_set_blob(sk_disk, smart_blob->data, smart_blob->len);
+ if (sk_disk_smart_get_temperature(sk_disk, &temperature) < 0) {
+ g_debug("Error getting temperature from AtaSmartBlob");
+ g_free(sk_disk);
+ g_array_free(smart_blob, TRUE);
+ g_object_unref(sensor_proxy);
+ return;
+ }
+
+ /* Temperature is in mK, so convert it to K first */
+ temperature /= 1000;
+ info->temp = (gdouble)temperature - 273.15;
+
+ g_free(sk_disk);
+ g_array_free(smart_blob, TRUE);
+ g_object_unref(sensor_proxy);
}
/* This is the handler for the Changed() signal emitted by UDisks. */
static void udisks_changed_signal_cb(DBusGProxy *sensor_proxy) {
- const gchar *path;
- DevInfo *info;
+ const gchar *path;
+ DevInfo *info;
- path = dbus_g_proxy_get_path(sensor_proxy);
- g_debug("%s changed()", path);
- info = g_hash_table_lookup(devices, path);
+ path = dbus_g_proxy_get_path(sensor_proxy);
+ g_debug("%s changed()", path);
+ info = g_hash_table_lookup(devices, path);
- update_device(info);
+ update_device(info);
}
static void udisks_plugin_get_sensors(GList **sensors) {
- DBusGProxy *proxy, *sensor_proxy;
- GError *error = NULL;
- GPtrArray *paths;
- guint i;
- DevInfo *info;
-
- /* This connection will be used for everything, including the obtaining
- * of sensor data
- */
- connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
- if (connection == NULL)
- {
- g_debug("Failed to open connection to DBUS: %s",
- error->message);
- g_error_free(error);
- return;
- }
-
- /* This is the proxy which is only used once during the enumeration of
- * the device object paths
- */
- proxy = dbus_g_proxy_new_for_name(connection,
- UDISKS_BUS_NAME,
- UDISKS_OBJECT_PATH,
- UDISKS_INTERFACE_NAME);
-
- /* The object paths of the disks are enumerated and placed in an array
- * of object paths
- */
- if (!dbus_g_proxy_call(proxy, "EnumerateDevices", &error,
- G_TYPE_INVALID,
- dbus_g_type_get_collection("GPtrArray",
- DBUS_TYPE_G_OBJECT_PATH),
- &paths,
- G_TYPE_INVALID))
- {
- g_debug("Failed to enumerate disk devices: %s",
- error->message);
- g_error_free(error);
- g_object_unref(proxy);
- dbus_g_connection_unref(connection);
- connection = NULL;
- return;
- }
-
- for (i = 0; i < paths->len; i++) {
- /* This proxy is used to get the required data in order to build
- * up the list of sensors
- */
- GValue smart_available = G_VALUE_INIT;
- gchar *path = (gchar *)g_ptr_array_index(paths, i);
-
- sensor_proxy = dbus_g_proxy_new_for_name(connection,
- UDISKS_BUS_NAME,
- path,
- UDISKS_PROPERTIES_INTERFACE);
-
- if (dbus_g_proxy_call(sensor_proxy, "Get", &error,
- G_TYPE_STRING,
- UDISKS_BUS_NAME,
- G_TYPE_STRING,
- "DriveAtaSmartIsAvailable",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &smart_available, G_TYPE_INVALID)) {
- if (!g_value_get_boolean(&smart_available)) {
- g_debug("Drive at path '%s' does not support "
- "Smart monitoring... ignoring",
- path);
- g_object_unref(sensor_proxy);
- g_free (path);
- continue;
- }
-
- GValue model_v = G_VALUE_INIT;
- dbus_g_proxy_call(sensor_proxy, "Get", NULL,
- G_TYPE_STRING, UDISKS_BUS_NAME,
- G_TYPE_STRING, "DriveModel",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &model_v,
- G_TYPE_INVALID);
-
- GValue dev_v = G_VALUE_INIT;
- dbus_g_proxy_call(sensor_proxy, "Get", NULL,
- G_TYPE_STRING, UDISKS_BUS_NAME,
- G_TYPE_STRING, "DeviceFile",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &dev_v,
- G_TYPE_INVALID);
-
- GValue ids_v = G_VALUE_INIT;
- dbus_g_proxy_call(sensor_proxy, "Get", NULL,
- G_TYPE_STRING, UDISKS_BUS_NAME,
- G_TYPE_STRING, "DeviceFileById",
- G_TYPE_INVALID,
- G_TYPE_VALUE, &ids_v,
- G_TYPE_INVALID);
-
- g_object_unref(sensor_proxy);
-
- sensor_proxy = dbus_g_proxy_new_for_name(connection,
- UDISKS_BUS_NAME,
- path,
- UDISKS_DEVICE_INTERFACE_NAME);
-
- /* Use the Changed() signal emitted from UDisks to
- * get the temperature immediately if it changes rather
- * than waiting to poll
- */
- dbus_g_proxy_add_signal(sensor_proxy, "Changed",
- G_TYPE_INVALID);
-
- dbus_g_proxy_connect_signal(sensor_proxy, "Changed",
- G_CALLBACK(udisks_changed_signal_cb),
- path, NULL);
-
-
- gchar *model = g_value_get_string(&model_v);
- gchar *dev = g_value_get_string(&dev_v);
- GStrv ids = g_value_get_boxed(&ids_v);
-
- gchar *id = ids != NULL && ids[0] != NULL ? ids[0] : dev;
-
- info = g_malloc0(sizeof(DevInfo));
- if (devices == NULL)
- {
- devices = g_hash_table_new(g_str_hash,
- g_str_equal);
- }
- info->id = g_strdup(id);
- info->path = g_strdup(path);
- info->sensor_proxy = sensor_proxy;
- /* Set the device status changed as TRUE because we need
- * to get the initial temperature reading
- */
- info->temp = 0.0;
- g_hash_table_insert(devices, info->id, info);
-
- /* Write the sensor data */
- sensors_applet_plugin_add_sensor(sensors,
- id,
- "Disk Temperature",
- model,
- TEMP_SENSOR,
- FALSE,
- HDD_ICON,
- DEFAULT_GRAPH_COLOR);
- g_strfreev(ids);
- g_free(model);
- g_free(dev);
- g_debug("Added %s %s", path, id);
- } else {
- g_debug ("Cannot obtain data for device: %s\n"
- "Error: %s\n",
- path,
- error->message);
- g_error_free (error);
- error = NULL;
- g_object_unref(sensor_proxy);
- }
- g_free(path);
- }
- g_ptr_array_free(paths, TRUE);
- g_object_unref(proxy);
- if (devices == NULL)
- {
- dbus_g_connection_unref(connection);
- connection = NULL;
- }
+ DBusGProxy *proxy, *sensor_proxy;
+ GError *error = NULL;
+ GPtrArray *paths;
+ guint i;
+ DevInfo *info;
+
+ /* This connection will be used for everything, including the obtaining of sensor data */
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL)
+ {
+ g_debug("Failed to open connection to DBUS: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ /* This is the proxy which is only used once during the enumeration of the device object paths */
+ proxy = dbus_g_proxy_new_for_name(connection,
+ UDISKS_BUS_NAME,
+ UDISKS_OBJECT_PATH,
+ UDISKS_INTERFACE_NAME);
+
+ /* The object paths of the disks are enumerated and placed in an array of object paths */
+ if (!dbus_g_proxy_call(proxy, "EnumerateDevices", &error,
+ G_TYPE_INVALID,
+ dbus_g_type_get_collection("GPtrArray",
+ DBUS_TYPE_G_OBJECT_PATH),
+ &paths,
+ G_TYPE_INVALID)) {
+
+ g_debug("Failed to enumerate disk devices: %s", error->message);
+ g_error_free(error);
+ g_object_unref(proxy);
+ dbus_g_connection_unref(connection);
+ connection = NULL;
+ return;
+ }
+
+ for (i = 0; i < paths->len; i++) {
+ /* This proxy is used to get the required data in order to build up the list of sensors */
+ GValue smart_available = G_VALUE_INIT;
+ gchar *path = (gchar *)g_ptr_array_index(paths, i);
+
+ sensor_proxy = dbus_g_proxy_new_for_name(connection,
+ UDISKS_BUS_NAME,
+ path,
+ UDISKS_PROPERTIES_INTERFACE);
+
+ if (dbus_g_proxy_call(sensor_proxy, "Get", &error,
+ G_TYPE_STRING,
+ UDISKS_BUS_NAME,
+ G_TYPE_STRING,
+ "DriveAtaSmartIsAvailable",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &smart_available, G_TYPE_INVALID)) {
+
+ if (!g_value_get_boolean(&smart_available)) {
+ g_debug("Drive at path '%s' does not support Smart monitoring... ignoring", path);
+ g_object_unref(sensor_proxy);
+ g_free (path);
+ continue;
+ }
+
+ GValue model_v = G_VALUE_INIT;
+ dbus_g_proxy_call(sensor_proxy, "Get", NULL,
+ G_TYPE_STRING, UDISKS_BUS_NAME,
+ G_TYPE_STRING, "DriveModel",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &model_v,
+ G_TYPE_INVALID);
+
+ GValue dev_v = G_VALUE_INIT;
+ dbus_g_proxy_call(sensor_proxy, "Get", NULL,
+ G_TYPE_STRING, UDISKS_BUS_NAME,
+ G_TYPE_STRING, "DeviceFile",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &dev_v,
+ G_TYPE_INVALID);
+
+ GValue ids_v = G_VALUE_INIT;
+ dbus_g_proxy_call(sensor_proxy, "Get", NULL,
+ G_TYPE_STRING, UDISKS_BUS_NAME,
+ G_TYPE_STRING, "DeviceFileById",
+ G_TYPE_INVALID,
+ G_TYPE_VALUE, &ids_v,
+ G_TYPE_INVALID);
+
+ g_object_unref(sensor_proxy);
+
+ sensor_proxy = dbus_g_proxy_new_for_name(connection,
+ UDISKS_BUS_NAME,
+ path,
+ UDISKS_DEVICE_INTERFACE_NAME);
+
+ /* Use the Changed() signal emitted from UDisks to
+ * get the temperature immediately if it changes rather
+ * than waiting to poll
+ */
+ dbus_g_proxy_add_signal(sensor_proxy, "Changed", G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal(sensor_proxy, "Changed",
+ G_CALLBACK(udisks_changed_signal_cb),
+ path, NULL);
+
+ gchar *model = g_value_get_string(&model_v);
+ gchar *dev = g_value_get_string(&dev_v);
+ GStrv ids = g_value_get_boxed(&ids_v);
+
+ gchar *id = ids != NULL && ids[0] != NULL ? ids[0] : dev;
+
+ info = g_malloc0(sizeof(DevInfo));
+ if (devices == NULL)
+ {
+ devices = g_hash_table_new(g_str_hash, g_str_equal);
+ }
+ info->id = g_strdup(id);
+ info->path = g_strdup(path);
+ info->sensor_proxy = sensor_proxy;
+ /* Set the device status changed as TRUE because we need
+ * to get the initial temperature reading
+ */
+ info->temp = 0.0;
+ g_hash_table_insert(devices, info->id, info);
+
+ /* Write the sensor data */
+ sensors_applet_plugin_add_sensor(sensors,
+ id,
+ "Disk Temperature",
+ model,
+ TEMP_SENSOR,
+ FALSE,
+ HDD_ICON,
+ DEFAULT_GRAPH_COLOR);
+
+ g_strfreev(ids);
+ g_free(model);
+ g_free(dev);
+ g_debug("Added %s %s", path, id);
+ } else {
+ g_debug ("Cannot obtain data for device: %s\n"
+ "Error: %s\n",
+ path,
+ error->message);
+ g_error_free (error);
+ error = NULL;
+ g_object_unref(sensor_proxy);
+ }
+ g_free(path);
+ } /* end of for */
+
+ g_ptr_array_free(paths, TRUE);
+ g_object_unref(proxy);
+ if (devices == NULL)
+ {
+ dbus_g_connection_unref(connection);
+ connection = NULL;
+ }
}
static gdouble udisks_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
- DevInfo *info;
-
- info = (DevInfo *)g_hash_table_lookup(devices, path);
- if (info == NULL)
- {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0,
- "Error finding disk with path %s", path);
- return 0.0;
- }
-
- if (info->error)
- {
- *error = info->error;
- info->error = NULL;
- return 0.0;
- }
- /* update value since Changed() signal doesn't fire manually enough so
- * poll instead */
- update_device(info);
- return info->temp;
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+ DevInfo *info;
+
+ info = (DevInfo *)g_hash_table_lookup(devices, path);
+ if (info == NULL)
+ {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Error finding disk with path %s", path);
+ return 0.0;
+ }
+
+ if (info->error)
+ {
+ *error = info->error;
+ info->error = NULL;
+ return 0.0;
+ }
+
+ /* update value since Changed() signal doesn't fire manually enough so poll instead */
+ update_device(info);
+ return info->temp;
}
static GList *udisks_plugin_init(void) {
- GList *sensors = NULL;
+ GList *sensors = NULL;
- udisks_plugin_get_sensors(&sensors);
+ udisks_plugin_get_sensors(&sensors);
- return sensors;
+ return sensors;
}
const gchar *sensors_applet_plugin_name(void)
{
- return plugin_name;
+ return plugin_name;
}
GList *sensors_applet_plugin_init(void)
{
- return udisks_plugin_init();
+ return udisks_plugin_init();
}
gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
- return udisks_plugin_get_sensor_value(path, id, type, error);
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+
+ return udisks_plugin_get_sensor_value(path, id, type, error);
}
diff --git a/plugins/udisks2/udisks2-plugin.c b/plugins/udisks2/udisks2-plugin.c
index 2fe401e..c23d09d 100644
--- a/plugins/udisks2/udisks2-plugin.c
+++ b/plugins/udisks2/udisks2-plugin.c
@@ -1,6 +1,4 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * vim: sts=0 sw=8 ts=8 tw=78 noexpandtab
- *
+/*
* Copyright (C) 2009 Pramod Dematagoda <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
@@ -36,7 +34,6 @@ syslog(LOG_ERR, "hellodd");
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif /* HAVE_CONFIG_H */
@@ -67,11 +64,11 @@ syslog(LOG_ERR, "hellodd");
* Info about a single sensor
*/
typedef struct _DevInfo{
- gchar *path;
- gchar *id;
- gdouble temp;
- GDBusProxy *sensor_proxy; // dbus object
- GError *error;
+ gchar *path;
+ gchar *id;
+ gdouble temp;
+ GDBusProxy *sensor_proxy; // dbus object
+ GError *error;
} DevInfo;
@@ -84,64 +81,58 @@ GHashTable *devices = NULL;
GDBusConnection *connection = NULL;
-static void update_device(DevInfo *info)
-{
- GError *error = NULL;
- GVariant *tempgvar = NULL;
- GVariant *tempgvar2 = NULL;
- gdouble temp;
+static void update_device(DevInfo *info) {
+ GError *error = NULL;
+ GVariant *tempgvar = NULL;
+ GVariant *tempgvar2 = NULL;
+ gdouble temp;
- // check valid input parameter
- g_return_if_fail(info != NULL);
+ // check valid input parameter
+ g_return_if_fail(info != NULL);
- // check connection too
- g_return_if_fail(connection != NULL);
+ // check connection too
+ g_return_if_fail(connection != NULL);
- g_clear_error(&info->error);
+ g_clear_error(&info->error);
// for the udisks plugin a new sensor_proxy was created here, which seems stupid, as one is already stored in the DevInfo struct
// I only create one direct connect proxy here in this function
- // check for sensor_proxy, which should exist at this point, make one if necessary and save it into DevInfo
- // this is used to get the temp value the direct way
- if(NULL == info->sensor_proxy)
- {
- info->sensor_proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
- UDISKS2_BUS_NAME,
- info->path,
- UDISKS2_PROPERTIES_INTERFACE,
- NULL, &error
- );
-
- // check, just to be sure
- if (NULL == info->sensor_proxy)
- {
+ // check for sensor_proxy, which should exist at this point, make one if necessary and save it into DevInfo
+ // this is used to get the temp value the direct way
+ if(NULL == info->sensor_proxy) {
+ info->sensor_proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ UDISKS2_BUS_NAME,
+ info->path,
+ UDISKS2_PROPERTIES_INTERFACE,
+ NULL, &error );
+
+ // check, just to be sure
+ if (NULL == info->sensor_proxy) {
#ifdef UD2PD
syslog(LOG_ERR, "Failed to get drive temperature 1");
#endif
- g_debug("Failed to get drive temperature 1: %s",
- error->message);
- g_clear_error(&error);
- return;
- }
- }
+ g_debug("Failed to get drive temperature 1: %s", error->message);
+ g_clear_error(&error);
+ return;
+ }
+ }
// "DriveAtaSmartTimeCollected" in ud2 is "drive ata SmartUpdated"
// fd: The point in time (seconds since the Unix Epoch) that the SMART status was updated or 0 if never updated.
// should we bother getting this time??
/*
- if (!g_dbus_proxy_call_sync(sensor_proxy, "Get", NULL,
- G_TYPE_STRING, UDISKS2_BUS_NAME,
- G_TYPE_STRING, "DriveAtaSmartTimeCollected", G_TYPE_INVALID,
- G_TYPE_VALUE, &smart_time,
- G_TYPE_INVALID) ||
- !g_value_get_uint64(&smart_time))
- {
- g_object_unref(sensor_proxy);
- return;
- }
+ if (!g_dbus_proxy_call_sync(sensor_proxy, "Get", NULL,
+ G_TYPE_STRING, UDISKS2_BUS_NAME,
+ G_TYPE_STRING, "DriveAtaSmartTimeCollected", G_TYPE_INVALID,
+ G_TYPE_VALUE, &smart_time,
+ G_TYPE_INVALID) || !g_value_get_uint64(&smart_time)) {
+
+ g_object_unref(sensor_proxy);
+ return;
+ }
*/
@@ -154,56 +145,50 @@ syslog(LOG_ERR, "Failed to get drive temperature 1");
// this smartblob was needed, bc there was no other way to get the smart temperature from udisks
/*
- if (!g_dbus_proxy_call_sync(sensor_proxy, "Get", &info->error,
- G_TYPE_STRING, UDISKS2_BUS_NAME,
- G_TYPE_STRING, "DriveAtaSmartBlob", G_TYPE_INVALID,
- G_TYPE_VALUE, &smart_blob_val,
- G_TYPE_INVALID))
- {
- g_debug("Error getting DriveAtaSmartBlob %s",
- info->error ? info->error->message : "NULL");
- g_object_unref(sensor_proxy);
- return;
- }
- smart_blob = g_value_get_boxed(&smart_blob_val);
-
- sk_disk_open(NULL, &sk_disk);
- sk_disk_set_blob(sk_disk, smart_blob->data, smart_blob->len);
- if (sk_disk_smart_get_temperature(sk_disk, &temperature) < 0)
- {
- g_debug("Error getting temperature from AtaSmartBlob");
- g_free(sk_disk);
- g_array_free(smart_blob, TRUE);
- g_object_unref(sensor_proxy);
- return;
- }
+ if (!g_dbus_proxy_call_sync(sensor_proxy, "Get", &info->error,
+ G_TYPE_STRING, UDISKS2_BUS_NAME,
+ G_TYPE_STRING, "DriveAtaSmartBlob", G_TYPE_INVALID,
+ G_TYPE_VALUE, &smart_blob_val,
+ G_TYPE_INVALID)) {
+
+ g_debug("Error getting DriveAtaSmartBlob %s", info->error ? info->error->message : "NULL");
+ g_object_unref(sensor_proxy);
+ return;
+ }
+ smart_blob = g_value_get_boxed(&smart_blob_val);
+
+ sk_disk_open(NULL, &sk_disk);
+ sk_disk_set_blob(sk_disk, smart_blob->data, smart_blob->len);
+ if (sk_disk_smart_get_temperature(sk_disk, &temperature) < 0) {
+ g_debug("Error getting temperature from AtaSmartBlob");
+ g_free(sk_disk);
+ g_array_free(smart_blob, TRUE);
+ g_object_unref(sensor_proxy);
+ return;
+ }
*/
- // directly asking the device's DBus object for the temp
- tempgvar = g_dbus_proxy_call_sync(info->sensor_proxy, "Get",
- g_variant_new ("(ss)",
- UDISKS2_DEVICE_INTERFACE2_NAME,
- "SmartTemperature"), // parameters
- G_DBUS_CALL_FLAGS_NONE, // flags
- -1, // timeout
- NULL, // cancellable
- &error);
+ // directly asking the device's DBus object for the temp
+ tempgvar = g_dbus_proxy_call_sync(info->sensor_proxy, "Get",
+ g_variant_new ("(ss)",
+ UDISKS2_DEVICE_INTERFACE2_NAME,
+ "SmartTemperature"), // parameters
+ G_DBUS_CALL_FLAGS_NONE, // flags
+ -1, // timeout
+ NULL, // cancellable
+ &error);
- if (NULL == tempgvar)
- {
+ if (NULL == tempgvar) {
#ifdef UD2PD
syslog(LOG_ERR, "Failed to get drive temperature 2");
#endif
- g_debug("Failed to get drive temperature 2: %s",
- error->message);
- g_clear_error(&error);
- // throw away proxy, maybe next time it will be better
- g_clear_object(&info->sensor_proxy);
- return;
- }
- else
- {
+ g_debug("Failed to get drive temperature 2: %s", error->message);
+ g_clear_error(&error);
+ // throw away proxy, maybe next time it will be better
+ g_clear_object(&info->sensor_proxy);
+ return;
+ } else {
#ifdef UD2PD
syslog(LOG_ERR, "tempgvar value: %s", g_variant_print(tempgvar, TRUE));
@@ -211,25 +196,25 @@ syslog(LOG_ERR, "tempgvar value: %s", g_variant_print(tempgvar, TRUE));
//syslog(LOG_ERR, "tempgvar value: %s", g_variant_print(g_variant_get_variant(g_variant_get_child_value(tempgvar, 0)), TRUE));
#endif
- // tempgvar comes back as sg along the lines of array(gvariant(tempasdouble))
- // hence unpacking
- // need to free up every param / return value, so can't do it like:
- //temp = g_variant_get_double(g_variant_get_variant(g_variant_get_child_value(tempgvar, 0)));
- tempgvar2 = g_variant_get_child_value(tempgvar, 0);
- g_variant_unref(tempgvar);
- tempgvar = g_variant_get_variant(tempgvar2);
- g_variant_unref(tempgvar2);
- temp = g_variant_get_double(tempgvar);
- g_variant_unref(tempgvar);
+ // tempgvar comes back as sg along the lines of array(gvariant(tempasdouble))
+ // hence unpacking
+ // need to free up every param / return value, so can't do it like:
+ //temp = g_variant_get_double(g_variant_get_variant(g_variant_get_child_value(tempgvar, 0)));
+ tempgvar2 = g_variant_get_child_value(tempgvar, 0);
+ g_variant_unref(tempgvar);
+ tempgvar = g_variant_get_variant(tempgvar2);
+ g_variant_unref(tempgvar2);
+ temp = g_variant_get_double(tempgvar);
+ g_variant_unref(tempgvar);
- // temp in K
- info->temp = temp - 273.15;
+ // temp in K
+ info->temp = temp - 273.15;
#ifdef UD2PD
syslog(LOG_ERR, "Refresh udisks2 device temp: '%f'\n", info->temp);
#endif
- }
+ }
}
@@ -239,15 +224,15 @@ syslog(LOG_ERR, "Refresh udisks2 device temp: '%f'\n", info->temp);
/* This is the handler for the Changed() signal emitted by UDisks. */
/*
static void udisks2_changed_signal_cb(GDBusProxy *sensor_proxy) {
- const gchar *path;
- DevInfo *info;
+ const gchar *path;
+ DevInfo *info;
- // fd2: Gets the object path sensor_proxy is for.
- path = g_dbus_proxy_get_object_path(sensor_proxy);
- g_debug("%s changed()", path);
- info = g_hash_table_lookup(devices, path);
+ // fd2: Gets the object path sensor_proxy is for.
+ path = g_dbus_proxy_get_object_path(sensor_proxy);
+ g_debug("%s changed()", path);
+ info = g_hash_table_lookup(devices, path);
-// update_device(info);
+// update_device(info);
}
*/
@@ -262,133 +247,125 @@ static void udisks2_plugin_get_sensors(GList **sensors) {
syslog(LOG_ERR, "fstart");
#endif
- GDBusProxy *proxy = NULL;
- GError *error = NULL;
+ GDBusProxy *proxy = NULL;
+ GError *error = NULL;
- DevInfo *info;
+ DevInfo *info;
- /* This connection will be used for everything, including the obtaining
- * of sensor data
- */
- // fd1: Returns a connection to the given bus. The connection is a global variable shared with other callers of this function.
- // fd2: Synchronously connects to the message bus specified by bus_type . Note that the returned object may shared with other callers, e.g. if two separate parts of a process calls this function with the same bus_type , they will share the same object.
- connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (NULL == connection)
- {
+ /* This connection will be used for everything, including the obtaining
+ * of sensor data
+ */
+ // fd1: Returns a connection to the given bus. The connection is a global variable shared with other callers of this function.
+ // fd2: Synchronously connects to the message bus specified by bus_type . Note that the returned object may shared with other callers, e.g. if two separate parts of a process calls this function with the same bus_type , they will share the same object.
+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (NULL == connection) {
#ifdef UD2PD
syslog(LOG_ERR, "dbus conn fail");
#endif
- g_debug("Failed to open connection to DBUS: %s",
- error->message);
- g_clear_error(&error);
- return;
- }
+ g_debug("Failed to open connection to DBUS: %s", error->message);
+ g_clear_error(&error);
+ return;
+ }
#ifdef UD2PD
syslog(LOG_ERR, "dbus conn success");
#endif
- /* This was the proxy which is only used once during the enumeration of
- * the device object paths
- */
- // I use it to get all info of all devices at once
- // fd1: Creates a new proxy for a remote interface exported by a connection on a message bus.
- // fd2: Creates a proxy for accessing interface_name on the remote object at object_path owned by name at connection and synchronously loads D-Bus properties unless the G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
- proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
- UDISKS2_BUS_NAME,
- UDISKS2_OBJECT_PATH,
- UDISKS2_INTERFACE_NAME,
- NULL, &error
- );
-
- if (NULL == proxy)
- {
+ /* This was the proxy which is only used once during the enumeration of
+ * the device object paths
+ */
+ // I use it to get all info of all devices at once
+ // fd1: Creates a new proxy for a remote interface exported by a connection on a message bus.
+ // fd2: Creates a proxy for accessing interface_name on the remote object at object_path owned by name at connection and synchronously loads D-Bus properties unless the G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES flag is used.
+ proxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+ UDISKS2_BUS_NAME,
+ UDISKS2_OBJECT_PATH,
+ UDISKS2_INTERFACE_NAME,
+ NULL, &error );
+
+ if (NULL == proxy) {
#ifdef UD2PD
syslog(LOG_ERR, "dbus conn proxy fail");
#endif
- g_debug("dbus conn proxy fail: %s",
- error->message);
- g_clear_error(&error);
- g_clear_object(&connection);
- return;
- }
+ g_debug("dbus conn proxy fail: %s", error->message);
+ g_clear_error(&error);
+ g_clear_object(&connection);
+ return;
+ }
#ifdef UD2PD
syslog(LOG_ERR, "dbus conn proxy success");
#endif
- /* The object paths of the disks are enumerated and placed in an array
- * of object paths
- */
- // fd1: Function for synchronously invoking a method and receiving reply values.
- // fd2: Synchronously invokes the method_name method on proxy.
- // called "EnumerateDevices" method on UDisks object through dbus
- // which returned an array of objectpaths
- // "GetManagedObjects" returns dict of (objectpath, (dict of (string [ie. if. name], dict of(string [ie. property name], variant [ie. prop. value]))))
+ /* The object paths of the disks are enumerated and placed in an array
+ * of object paths
+ */
+ // fd1: Function for synchronously invoking a method and receiving reply values.
+ // fd2: Synchronously invokes the method_name method on proxy.
+ // called "EnumerateDevices" method on UDisks object through dbus
+ // which returned an array of objectpaths
+ // "GetManagedObjects" returns dict of (objectpath, (dict of (string [ie. if. name], dict of(string [ie. property name], variant [ie. prop. value]))))
- // g_dbus_proxy_call_sync() returns NULL on error, GVariant * otherwise
- // need second param to prevent memory leak
- GVariant *managed_objects, *managed_objects2;
+ // g_dbus_proxy_call_sync() returns NULL on error, GVariant * otherwise
+ // need second param to prevent memory leak
+ GVariant *managed_objects, *managed_objects2;
- managed_objects2 = g_dbus_proxy_call_sync(proxy, "GetManagedObjects",
- NULL, // parameters
- G_DBUS_CALL_FLAGS_NONE, // flags
- -1, // timeout
- NULL, // cancellable
- &error);
+ managed_objects2 = g_dbus_proxy_call_sync(proxy, "GetManagedObjects",
+ NULL, // parameters
+ G_DBUS_CALL_FLAGS_NONE, // flags
+ -1, // timeout
+ NULL, // cancellable
+ &error);
- if (NULL == managed_objects2)
- {
+ if (NULL == managed_objects2) {
#ifdef UD2PD
syslog(LOG_ERR, "Failed to enumerate disk devices");
#endif
- g_debug("Failed to enumerate disk devices: %s",
- error->message);
- g_clear_error(&error);
- g_clear_object(&proxy);
- g_clear_object(&connection);
- return;
- }
+ g_debug("Failed to enumerate disk devices: %s", error->message);
+ g_clear_error(&error);
+ g_clear_object(&proxy);
+ g_clear_object(&connection);
+ return;
+ }
- // the result dictionary is enclosed in an array, unpack
- managed_objects = g_variant_get_child_value(managed_objects2, 0);
- g_variant_unref(managed_objects2);
+ // the result dictionary is enclosed in an array, unpack
+ managed_objects = g_variant_get_child_value(managed_objects2, 0);
+ g_variant_unref(managed_objects2);
#ifdef UD2PD
//syslog(LOG_ERR, "managed_objects type: %s", g_variant_print(managed_objects, TRUE));
syslog(LOG_ERR, "success to enumerate disk devices");
#endif
- // iterator for the result dictionary
+ // iterator for the result dictionary
- // iterator code is based on the g_variant_iter_next() documentation
- // iter is freed if the GVariant is, when using g_variant_iter_init()
- GVariantIter iter;
- gchar *key; // object path (like '/org/freedesktop/UDisks2/drives/Samsung_SSD_840_EVO_250GB_*insert drive serial nr.*')
- GVariant *value;
+ // iterator code is based on the g_variant_iter_next() documentation
+ // iter is freed if the GVariant is, when using g_variant_iter_init()
+ GVariantIter iter;
+ gchar *key; // object path (like '/org/freedesktop/UDisks2/drives/Samsung_SSD_840_EVO_250GB_*insert drive serial nr.*')
+ GVariant *value;
#ifdef UD2PD
// log collection size
syslog(LOG_ERR, "iter init count: %d", (int) g_variant_iter_init(&iter, managed_objects));
#else
- g_variant_iter_init(&iter, managed_objects);
+ g_variant_iter_init(&iter, managed_objects);
#endif
- // "{sv}" is a GVariant format string
- // {} dictionary of, s string, v GVariant
- // changed to "{oa{sa{sv}}}" on error message 'the GVariant format string '{sv}' has a type of '{sv}' but the given value has a type of 'a{oa{sa{sv}}}''
- // a is array, o is object path
- // NOO!! the right format string is "{o@*}", which means get an object path into the 1st variable (key)
- // and get 'everything else' (as a GVariant) into the 2nd variable (value)
- // needs the & before the key and value params!
- while (g_variant_iter_next(&iter, "{o@*}", &key, &value))
- {
+ // "{sv}" is a GVariant format string
+ // {} dictionary of, s string, v GVariant
+ // changed to "{oa{sa{sv}}}" on error message 'the GVariant format string '{sv}' has a type of '{sv}' but the given value has a type of 'a{oa{sa{sv}}}''
+ // a is array, o is object path
+ // NOO!! the right format string is "{o@*}", which means get an object path into the 1st variable (key)
+ // and get 'everything else' (as a GVariant) into the 2nd variable (value)
+ // needs the & before the key and value params!
+ while (g_variant_iter_next(&iter, "{o@*}", &key, &value)) {
#ifdef UD2PD
syslog(LOG_ERR, "in iter while loop");
@@ -396,43 +373,42 @@ syslog(LOG_ERR, "key value: %s", key);
//syslog(LOG_ERR, "value type: %s", g_variant_print(value, TRUE));
#endif
- // level 2
- // create a dictionary of value
- // the two interface names that we are searching for are known and defined
- // can't use GVariantDict, it only supports '{sv}' but the given value has a type of '{sa{sv}}'
- // using general lookup
+ // level 2
+ // create a dictionary of value
+ // the two interface names that we are searching for are known and defined
+ // can't use GVariantDict, it only supports '{sv}' but the given value has a type of '{sa{sv}}'
+ // using general lookup
- GVariant *propdict; // drive data
- GVariant *propdict2; // drive smart data
+ GVariant *propdict; // drive data
+ GVariant *propdict2; // drive smart data
- // make two dictionaries that contain the properties of the drive interfaces
- propdict = g_variant_lookup_value(value, UDISKS2_DEVICE_INTERFACE_NAME, G_VARIANT_TYPE_DICTIONARY);
- propdict2 = g_variant_lookup_value(value, UDISKS2_DEVICE_INTERFACE2_NAME, G_VARIANT_TYPE_DICTIONARY);
+ // make two dictionaries that contain the properties of the drive interfaces
+ propdict = g_variant_lookup_value(value, UDISKS2_DEVICE_INTERFACE_NAME, G_VARIANT_TYPE_DICTIONARY);
+ propdict2 = g_variant_lookup_value(value, UDISKS2_DEVICE_INTERFACE2_NAME, G_VARIANT_TYPE_DICTIONARY);
- // do we have the right ifname keys?
- if((NULL != propdict) && (NULL != propdict2))
- {
+ // do we have the right ifname keys?
+ if((NULL != propdict) && (NULL != propdict2)) {
#ifdef UD2PD
syslog(LOG_ERR, "propdict type: %s", g_variant_print(propdict, TRUE));
syslog(LOG_ERR, "propdict2 type: %s", g_variant_print(propdict2, TRUE));
#endif
- // get data
- gchar *id;
- gchar *model;
+ // get data
+ gchar *id;
+ gchar *model;
- gboolean smartenabled;
- gdouble temp;
+ gboolean smartenabled;
+ gdouble temp;
- // NULL, bc we don't care about the length of the string
- // typecast bc g_variant_get_string() returns const char*
- id = (gchar *) g_variant_get_string(g_variant_lookup_value(propdict, "Id", G_VARIANT_TYPE_STRING), NULL);
- model = (gchar *) g_variant_get_string(g_variant_lookup_value(propdict, "Model", G_VARIANT_TYPE_STRING), NULL);
+ // NULL, bc we don't care about the length of the string
+ // typecast bc g_variant_get_string() returns const char*
+ id = (gchar *) g_variant_get_string(g_variant_lookup_value(propdict, "Id", G_VARIANT_TYPE_STRING), NULL);
+ model = (gchar *) g_variant_get_string(g_variant_lookup_value(propdict, "Model", G_VARIANT_TYPE_STRING), NULL);
- smartenabled = g_variant_get_boolean(g_variant_lookup_value(propdict2, "SmartEnabled", G_VARIANT_TYPE_BOOLEAN));
- temp = g_variant_get_double(g_variant_lookup_value(propdict2, "SmartTemperature", G_VARIANT_TYPE_DOUBLE));
+ smartenabled = g_variant_get_boolean(g_variant_lookup_value(propdict2, "SmartEnabled", G_VARIANT_TYPE_BOOLEAN));
+ temp = g_variant_get_double(g_variant_lookup_value(propdict2, "SmartTemperature", G_VARIANT_TYPE_DOUBLE));
#ifdef UD2PD
syslog(LOG_ERR, "Found udisks2 device id: '%s'\n", id);
@@ -442,144 +418,135 @@ syslog(LOG_ERR, "Found udisks2 device temp: '%f'\n", temp);
#endif
- // only go on if smart is enabled
- // save data
- if(smartenabled)
- {
+ // only go on if smart is enabled
+ // save data
+ if(smartenabled) {
- info = g_malloc0(sizeof(DevInfo));
- if (NULL == devices)
- {
- devices = g_hash_table_new(g_str_hash,
- g_str_equal);
- }
+ info = g_malloc0(sizeof(DevInfo));
+ if (NULL == devices) {
+ devices = g_hash_table_new(g_str_hash, g_str_equal);
+ }
- info->id = g_strdup(id);
- info->path = g_strdup(key);
+ info->id = g_strdup(id);
+ info->path = g_strdup(key);
- // temp in K
- // this could be left at 0.0, 2 seconds later it will be refreshed anyway
- info->temp = (gdouble)temp - 273.15;
- g_hash_table_insert(devices, info->id, info);
+ // temp in K
+ // this could be left at 0.0, 2 seconds later it will be refreshed anyway
+ info->temp = (gdouble)temp - 273.15;
+ g_hash_table_insert(devices, info->id, info);
- // Write the sensor data
- sensors_applet_plugin_add_sensor(sensors,
- id,
- "Disk Temperature",
- model,
- TEMP_SENSOR,
- FALSE,
- HDD_ICON,
- DEFAULT_GRAPH_COLOR);
+ // Write the sensor data
+ sensors_applet_plugin_add_sensor(sensors,
+ id,
+ "Disk Temperature",
+ model,
+ TEMP_SENSOR,
+ FALSE,
+ HDD_ICON,
+ DEFAULT_GRAPH_COLOR);
- g_debug("Added %s", id);
+ g_debug("Added %s", id);
#ifdef UD2PD
syslog(LOG_ERR, "Added %s", id);
#endif
- }
- else
- {
+ } else {
#ifdef UD2PD
syslog(LOG_ERR, "No temp data for device: %s\n", key);
#endif
- g_debug ("No temp data for device: %s\n", key);
- }
+ g_debug ("No temp data for device: %s\n", key);
+ }
#ifdef UD2PD
syslog(LOG_ERR, "b4 free1");
#endif
- g_free(id);
- g_free(model);
+ g_free(id);
+ g_free(model);
- }
+ }
#ifdef UD2PD
syslog(LOG_ERR, "b4 free2");
#endif
- // free propdict, propdict2
- // g_variant_dict_unref() may not work a few times, gives error
- // this one seems to do fine
- if(NULL != propdict) {g_variant_unref(propdict);}
- if(NULL != propdict2) {g_variant_unref(propdict2);}
+ // free propdict, propdict2
+ // g_variant_dict_unref() may not work a few times, gives error
+ // this one seems to do fine
+ if(NULL != propdict) {g_variant_unref(propdict);}
+ if(NULL != propdict2) {g_variant_unref(propdict2);}
#ifdef UD2PD
syslog(LOG_ERR, "b4 free3");
#endif
- g_free(key);
- g_variant_unref(value);
+ g_free(key);
+ g_variant_unref(value);
- } // end of while loop
+ } // end of while loop
- g_variant_unref(managed_objects);
- g_clear_object(&proxy);
- if (NULL == devices)
- {
- g_clear_object(&connection);
- }
+ g_variant_unref(managed_objects);
+ g_clear_object(&proxy);
+ if (NULL == devices) {
+ g_clear_object(&connection);
+ }
}
-
// this is the function called every refresh cycle
static gdouble udisks2_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
- DevInfo *info;
-
- // get device stuct from data store
- info = (DevInfo *)g_hash_table_lookup(devices, path);
- if (NULL == info)
- {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0,
- "Error finding disk with path %s", path);
- return 0.0;
- }
-
- if (info->error)
- {
- *error = info->error;
- info->error = NULL;
- return 0.0;
- }
-
- // refresh device temp
- /* update value since Changed() signal doesn't fire manually enough so
- * poll instead */
- update_device(info);
- return info->temp;
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+ DevInfo *info;
+
+ // get device stuct from data store
+ info = (DevInfo *) g_hash_table_lookup(devices, path);
+ if (NULL == info) {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Error finding disk with path %s", path);
+ return 0.0;
+ }
+
+ if (info->error) {
+ *error = info->error;
+ info->error = NULL;
+ return 0.0;
+ }
+
+ // refresh device temp
+ /* update value since Changed() signal doesn't fire manually enough so
+ * poll instead */
+ update_device(info);
+ return info->temp;
}
// API functions
const gchar *sensors_applet_plugin_name(void)
{
- return plugin_name;
+ return plugin_name;
}
static GList *udisks2_plugin_init(void) {
- GList *sensors = NULL;
+ GList *sensors = NULL;
- udisks2_plugin_get_sensors(&sensors);
+ udisks2_plugin_get_sensors(&sensors);
- return sensors;
+ return sensors;
}
GList *sensors_applet_plugin_init(void)
{
- return udisks2_plugin_init();
+ return udisks2_plugin_init();
}
gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
- SensorType type,
- GError **error) {
- return udisks2_plugin_get_sensor_value(path, id, type, error);
+ const gchar *id,
+ SensorType type,
+ GError **error) {
+
+ return udisks2_plugin_get_sensor_value(path, id, type, error);
}