summaryrefslogtreecommitdiff
path: root/plugins/nvidia
diff options
context:
space:
mode:
authorinfo-cppsp <[email protected]>2017-11-18 16:20:36 +0100
committerraveit65 <[email protected]>2017-11-26 20:41:43 +0100
commit03d94bc09168713cdc3f9d0a51539d4b8398ba0d (patch)
treeaf48fac3a9174bb83a3505869f4bffa4d9402338 /plugins/nvidia
parent93dd9f3d232220ec4a807f122a9fae1e71f06f0f (diff)
downloadmate-sensors-applet-03d94bc09168713cdc3f9d0a51539d4b8398ba0d.tar.bz2
mate-sensors-applet-03d94bc09168713cdc3f9d0a51539d4b8398ba0d.tar.xz
Fix indents 03
Diffstat (limited to 'plugins/nvidia')
-rw-r--r--plugins/nvidia/nvidia-plugin.c309
1 files changed, 157 insertions, 152 deletions
diff --git a/plugins/nvidia/nvidia-plugin.c b/plugins/nvidia/nvidia-plugin.c
index 46a7b32..4a30e34 100644
--- a/plugins/nvidia/nvidia-plugin.c
+++ b/plugins/nvidia/nvidia-plugin.c
@@ -40,178 +40,183 @@ const gchar *plugin_name = "nvidia";
Display *nvidia_sensors_dpy; /* the connection to the X server */
/* returns the value of the sensor */
-static gdouble nvidia_plugin_get_sensor_value(const gchar *path,
- const gchar *id,
+static gdouble nvidia_plugin_get_sensor_value(const gchar *path,
+ const gchar *id,
SensorType type,
- GError **error)
-{
- Bool res;
- int temp;
- int i;
-
- i = g_ascii_strtoll(id + strlen("GPU"), NULL, 10);
- if (g_ascii_strcasecmp(path, THERMAL_SENSOR_TEMP) == 0) {
- res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
- i,
- 0,
- NV_CTRL_THERMAL_SENSOR_READING,
- &temp);
- } else if (g_ascii_strcasecmp(path, THERMAL_COOLER_LEVEL) == 0) {
- res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_COOLER,
- i,
- 0,
- NV_CTRL_THERMAL_COOLER_LEVEL,
- &temp);
- } else if (g_ascii_strcasecmp(path, GPU_CORE_TEMP) == 0) {
- res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- i,
- 0,
- NV_CTRL_GPU_CORE_TEMPERATURE,
- &temp);
- } else if (g_ascii_strcasecmp(path, AMBIENT_TEMP) == 0) {
- res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- i,
- 0,
- NV_CTRL_AMBIENT_TEMPERATURE,
- &temp);
- } else {
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Invalid path string passed to nvidia_plugin_get_sensor_value");
- return 0;
- }
-
-
- if (res != True) {
- /* when res isn't true something went wrong */
- g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "XNVCTRLQueryAttribute returned false");
- return 0;
- }
-
- /* convert the int to gdouble and return it */
- return (gdouble)temp;
+ GError **error) {
+
+ Bool res;
+ int temp;
+ int i;
+
+ i = g_ascii_strtoll(id + strlen("GPU"), NULL, 10);
+ if (g_ascii_strcasecmp(path, THERMAL_SENSOR_TEMP) == 0) {
+ res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
+ i,
+ 0,
+ NV_CTRL_THERMAL_SENSOR_READING,
+ &temp);
+
+ } else if (g_ascii_strcasecmp(path, THERMAL_COOLER_LEVEL) == 0) {
+ res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_COOLER,
+ i,
+ 0,
+ NV_CTRL_THERMAL_COOLER_LEVEL,
+ &temp);
+
+ } else if (g_ascii_strcasecmp(path, GPU_CORE_TEMP) == 0) {
+ res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ i,
+ 0,
+ NV_CTRL_GPU_CORE_TEMPERATURE,
+ &temp);
+
+ } else if (g_ascii_strcasecmp(path, AMBIENT_TEMP) == 0) {
+ res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ i,
+ 0,
+ NV_CTRL_AMBIENT_TEMPERATURE,
+ &temp);
+
+ } else {
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Invalid path string passed to nvidia_plugin_get_sensor_value");
+ return 0;
+ }
+
+ if (res != True) {
+ /* when res isn't true something went wrong */
+ g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "XNVCTRLQueryAttribute returned false");
+ return 0;
+ }
+
+ /* convert the int to gdouble and return it */
+ return (gdouble)temp;
}
/* creates the connection to the X server and checks whether the
* NV-CONTROL extension is loaded */
-static GList *nvidia_plugin_init(void)
-{
- int dummy;
- int event_base, error_base;
- GList *sensors = NULL;
-
- /* create the connection to the X server */
- if (!(nvidia_sensors_dpy = XOpenDisplay(NULL))) {
- /* no connection to the X server avaible */
- return sensors;
- }
+static GList *nvidia_plugin_init(void) {
+ int dummy;
+ int event_base, error_base;
+ GList *sensors = NULL;
+
+ /* create the connection to the X server */
+ if (!(nvidia_sensors_dpy = XOpenDisplay(NULL))) {
+ /* no connection to the X server avaible */
+ return sensors;
+ }
- /* check if the NV-CONTROL extension is available on this X
+ /* check if the NV-CONTROL extension is available on this X
* server - if so add the two sensors if they exist */
- if (XNVCTRLQueryExtension(nvidia_sensors_dpy, &event_base, &error_base)) {
- int i, cnt;
-
- if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
- &cnt)) {
- for (i = 0; i < cnt; i++) {
- gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_SENSOR_TEMP);
-
- sensors_applet_plugin_add_sensor(&sensors,
- THERMAL_SENSOR_TEMP,
- id,
- _("GPU"),
- TEMP_SENSOR,
- TRUE,
- GPU_ICON,
- DEFAULT_GRAPH_COLOR);
-
- g_free(id);
- }
- }
-
- if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_COOLER,
- &cnt)) {
-
- for (i = 0; i < cnt; i++) {
- gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_COOLER_LEVEL);
-
- sensors_applet_plugin_add_sensor(&sensors,
- THERMAL_COOLER_LEVEL,
- id,
- _("GPU"),
- FAN_SENSOR,
- TRUE,
- FAN_ICON,
- DEFAULT_GRAPH_COLOR);
-
- g_free(id);
- }
- }
-
- if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- &cnt))
- {
- for (i = 0; i < cnt; i++)
- {
- if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- i,
- 0, NV_CTRL_GPU_CORE_TEMPERATURE, &dummy)) {
- gchar *id = g_strdup_printf("GPU%d%s", i, GPU_CORE_TEMP);
-
- sensors_applet_plugin_add_sensor(&sensors,
- GPU_CORE_TEMP,
- id,
- _("GPU"),
- TEMP_SENSOR,
- TRUE,
- GPU_ICON,
- DEFAULT_GRAPH_COLOR);
- g_free(id);
- }
- if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
- NV_CTRL_TARGET_TYPE_GPU,
- i,
- 0, NV_CTRL_AMBIENT_TEMPERATURE, &dummy)) {
- gchar *id = g_strdup_printf("GPU%d%s", i, AMBIENT_TEMP);
-
- sensors_applet_plugin_add_sensor(&sensors,
- AMBIENT_TEMP,
- id,
- _("Ambient"),
- TEMP_SENSOR,
- FALSE,
- GENERIC_ICON,
- DEFAULT_GRAPH_COLOR);
- g_free(id);
- }
- }
+ if (XNVCTRLQueryExtension(nvidia_sensors_dpy, &event_base, &error_base)) {
+ int i, cnt;
+
+ if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
+ &cnt)) {
+
+ for (i = 0; i < cnt; i++) {
+ gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_SENSOR_TEMP);
+
+ sensors_applet_plugin_add_sensor(&sensors,
+ THERMAL_SENSOR_TEMP,
+ id,
+ _("GPU"),
+ TEMP_SENSOR,
+ TRUE,
+ GPU_ICON,
+ DEFAULT_GRAPH_COLOR);
+
+ g_free(id);
+ }
+ }
+
+ if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_COOLER,
+ &cnt)) {
+
+ for (i = 0; i < cnt; i++) {
+ gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_COOLER_LEVEL);
+
+ sensors_applet_plugin_add_sensor(&sensors,
+ THERMAL_COOLER_LEVEL,
+ id,
+ _("GPU"),
+ FAN_SENSOR,
+ TRUE,
+ FAN_ICON,
+ DEFAULT_GRAPH_COLOR);
+
+ g_free(id);
+ }
+ }
+
+ if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ &cnt)) {
+
+ for (i = 0; i < cnt; i++) {
+ if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ i,
+ 0, NV_CTRL_GPU_CORE_TEMPERATURE, &dummy)) {
+
+ gchar *id = g_strdup_printf("GPU%d%s", i, GPU_CORE_TEMP);
+
+ sensors_applet_plugin_add_sensor(&sensors,
+ GPU_CORE_TEMP,
+ id,
+ _("GPU"),
+ TEMP_SENSOR,
+ TRUE,
+ GPU_ICON,
+ DEFAULT_GRAPH_COLOR);
+ g_free(id);
}
+ if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+ NV_CTRL_TARGET_TYPE_GPU,
+ i,
+ 0, NV_CTRL_AMBIENT_TEMPERATURE, &dummy)) {
+ gchar *id = g_strdup_printf("GPU%d%s", i, AMBIENT_TEMP);
+
+ sensors_applet_plugin_add_sensor(&sensors,
+ AMBIENT_TEMP,
+ id,
+ _("Ambient"),
+ TEMP_SENSOR,
+ FALSE,
+ GENERIC_ICON,
+ DEFAULT_GRAPH_COLOR);
+ g_free(id);
+ }
+ }
}
- return sensors;
+
+ }
+ return sensors;
}
-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 nvidia_plugin_init();
+ return nvidia_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 nvidia_plugin_get_sensor_value(path, id, type, error);
+
+ return nvidia_plugin_get_sensor_value(path, id, type, error);
}