+static double get_usage_att(char *atts, char *att)
+{
+ char *c, *key, *strv, *s;
+ size_t n;
+ double v;
+
+ c = atts;
+
+ v = UNKNOWN_DBL_VALUE;
+ while (*c) {
+ s = c;
+ n = 0;
+ while (*c) {
+ if (*c == '=')
+ break;
+ c++;
+ n++;
+ }
+
+ key = strndup(s, n);
+
+ if (*c)
+ c++;
+
+ n = 0;
+ s = c;
+ while (*c) {
+ if (*c == ',')
+ break;
+ c++;
+ n++;
+ }
+
+ strv = strndup(s, n);
+ if (!strcmp(key, att))
+ v = atoi(strv);
+
+ free(key);
+ free(strv);
+
+ if (v != UNKNOWN_DBL_VALUE)
+ break;
+
+ while (*c && (*c == ' ' || *c == ','))
+ c++;
+ }
+
+ return v;
+}
+
+static int get_usage(struct psensor *sensor)
+{
+ char *temp;
+ Bool res;
+
+ res = XNVCTRLQueryTargetStringAttribute(display,
+ NV_CTRL_TARGET_TYPE_GPU,
+ sensor->nvidia_id,
+ 0,
+ NV_CTRL_STRING_GPU_UTILIZATION,
+ &temp);
+
+ if (res == True)
+ return get_usage_att(temp, "graphics");
+
+ log_debug(_("NVIDIA proprietary driver not used or cannot "
+ "retrieve NVIDIA GPU usage."));
+ return 0;
+}
+
+static struct psensor *create_temp_sensor(int id, int values_len)