</term>
<listitem>
Nvidia graficcard support for the XNVCtrl library.
- Each option gives back one integer value:
- (threshold): the thresholdtemperature at which the gpu slows down
- (temp): gives the gpu current temperature
- (gpufreq): gives the current gpu frequency
- (memfreq): gives the current mem frequency
- (imagequality): which imagequality should be choosen by OpenGL applications
+ Each option can be shortened to the least significant part.
+ Temperatures are printed as float, all other values as integer.
+ <simplelist>
+ <member><command>threshold</command>:
+ the thresholdtemperature at which the gpu slows down
+ </member>
+ <member><command>temp</command>:
+ gives the gpu current temperature
+ </member>
+ <member><command>gpufreq</command>:
+ gives the current gpu frequency
+ </member>
+ <member><command>memfreq</command>:
+ gives the current mem frequency
+ </member>
+ <member><command>imagequality</command>:
+ which imagequality should be choosen by OpenGL applications
+ </member>
+ </simplelist>
<para></para>
</listitem>
</varlistentry>
}
#ifdef NVIDIA
END OBJ(nvidia, 0)
- if (!arg){
- CRIT_ERR("nvidia needs one argument "
- "[temp,threshold,gpufreq,memfreq,imagequality]");
- } else {
- if (strcmp(arg, "temp") == 0)
- obj->data.nvidia.type = NV_TEMP;
- else if (strcmp(arg, "threshold") == 0)
- obj->data.nvidia.type = NV_TEMP_THRESHOLD;
- else if (strcmp(arg, "gpufreq") == 0)
- obj->data.nvidia.type = NV_GPU_FREQ;
- else if (strcmp(arg, "memfreq") == 0)
- obj->data.nvidia.type = NV_MEM_FREQ;
- else if (strcmp(arg, "imagequality") == 0)
- obj->data.nvidia.type = NV_IMAGE_QUALITY;
- else
- CRIT_ERR("you have to give one of these arguments "
- "[temp,threshold,gpufreq,memfreq,imagequality");
- strncpy((char*)&obj->data.nvidia.arg, arg, 20);
+ if (!arg) {
+ CRIT_ERR("nvidia needs an argument\n");
+ } else if (set_nvidia_type(&obj->data.nvidia, arg)) {
+ CRIT_ERR("nvidia: invalid argument"
+ " specified: '%s'\n", arg);
}
#endif /* NVIDIA */
END {
}
#ifdef NVIDIA
OBJ(nvidia) {
- int hol = (strcmp((char*)&obj->data.nvidia.arg, "gpufreq")) ? 1 : 0;
- if(!(obj->data.nvidia.value = get_nvidia_value(obj->data.nvidia.type, display, hol)))
- snprintf(p, p_max_size, "value unavailible");
+ int value = get_nvidia_value(obj->data.nvidia.type, display);
+ if(value == -1)
+ snprintf(p, p_max_size, "N/A");
+ else if (obj->data.nvidia.print_as_float &&
+ value > 0 && value < 100)
+ snprintf(p, p_max_size, "%.1f", (float)value);
else
- spaced_print(p, p_max_size, "%*d", 4, "nvidia",
- 4, obj->data.nvidia.value);
-
+ snprintf(p, p_max_size, "%d", value);
}
#endif /* NVIDIA */
#include "hddtemp.h"
#endif /* HDDTEMP */
-/* in nvidia.c */
-#ifdef NVIDIA
-
-int get_nvidia_value(QUERY_ID qid, Display *dpy, int highorlow);
-
-#endif /* NVIDIA */
-
#endif
#include "nvidia.h"
-int get_nvidia_value(QUERY_ID qid, Display *dpy, int highorlow){
+int get_nvidia_value(QUERY_ID qid, Display *dpy){
int tmp;
if(!XNVCTRLQueryAttribute(dpy, 0, 0, qid, &tmp)){
- return 0;
- } else if (qid == NV_GPU_FREQ){
- if (highorlow == 1)
- return tmp >> 16;
- else
- return tmp & 0x0000FFFF;
- } else
- return tmp;
+ return -1;
+ }
+ /* FIXME: when are the low 2 bytes of NV_GPU_FREQ needed? */
+ if (qid == NV_GPU_FREQ)
+ return tmp >> 16;
+ return tmp;
}
+int set_nvidia_type(struct nvidia_s *nvidia, const char *arg)
+{
+ if (!arg || !arg[0] || !arg[1])
+ return 1;
+
+ nvidia->print_as_float = 0;
+ switch(arg[0]) {
+ case 't': // temp or threshold
+ nvidia->print_as_float = 1;
+ if (arg[1] == 'e')
+ nvidia->type = NV_TEMP;
+ else if (arg[1] == 'h')
+ nvidia->type = NV_TEMP_THRESHOLD;
+ else
+ return 1;
+ break;
+ case 'g': // gpufreq
+ nvidia->type = NV_GPU_FREQ;
+ break;
+ case 'm': // memfreq
+ nvidia->type = NV_MEM_FREQ;
+ break;
+ case 'i': // imagequality
+ nvidia->type = NV_IMAGE_QUALITY;
+ break;
+ default:
+ return 1;
+ }
+ return 0;
+}
*/
-#include <X11/Xlib.h>
-#include <NVCtrl/NVCtrlLib.h>
-
#ifndef NVIDIA_CONKY_H
#define NVIDIA_CONKY_H
+#include <X11/Xlib.h>
+#include <NVCtrl/NVCtrlLib.h>
+
typedef enum _QUERY_ID {
NV_TEMP = NV_CTRL_GPU_CORE_TEMPERATURE,
NV_TEMP_THRESHOLD = NV_CTRL_GPU_CORE_THRESHOLD,
struct nvidia_s {
int interval;
- int value;
- char arg[20];
+ int print_as_float;
QUERY_ID type;
};
+int get_nvidia_value(QUERY_ID qid, Display *dpy);
+int set_nvidia_type(struct nvidia_s *, const char *);
+
#endif