mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-02-04 21:18:33 +00:00
little simplification and improvement of $nvidia
* check only the unique part of the argument * print temperatures like all others (%.1f) * do argument parsing in nvidia.c (so all specific stuff is at one place) * little header cleanup git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1231 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
bea18942cd
commit
d23271777d
@ -1454,12 +1454,25 @@
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
Nvidia graficcard support for the XNVCtrl library.
|
Nvidia graficcard support for the XNVCtrl library.
|
||||||
Each option gives back one integer value:
|
Each option can be shortened to the least significant part.
|
||||||
(threshold): the thresholdtemperature at which the gpu slows down
|
Temperatures are printed as float, all other values as integer.
|
||||||
(temp): gives the gpu current temperature
|
<simplelist>
|
||||||
(gpufreq): gives the current gpu frequency
|
<member><command>threshold</command>:
|
||||||
(memfreq): gives the current mem frequency
|
the thresholdtemperature at which the gpu slows down
|
||||||
(imagequality): which imagequality should be choosen by OpenGL applications
|
</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>
|
<para></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
34
src/conky.c
34
src/conky.c
@ -4023,23 +4023,10 @@ static struct text_object *construct_text_object(const char *s,
|
|||||||
#ifdef NVIDIA
|
#ifdef NVIDIA
|
||||||
END OBJ(nvidia, 0)
|
END OBJ(nvidia, 0)
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
CRIT_ERR("nvidia needs one argument "
|
CRIT_ERR("nvidia needs an argument\n");
|
||||||
"[temp,threshold,gpufreq,memfreq,imagequality]");
|
} else if (set_nvidia_type(&obj->data.nvidia, arg)) {
|
||||||
} else {
|
CRIT_ERR("nvidia: invalid argument"
|
||||||
if (strcmp(arg, "temp") == 0)
|
" specified: '%s'\n", arg);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
#endif /* NVIDIA */
|
#endif /* NVIDIA */
|
||||||
END {
|
END {
|
||||||
@ -6321,13 +6308,14 @@ head:
|
|||||||
}
|
}
|
||||||
#ifdef NVIDIA
|
#ifdef NVIDIA
|
||||||
OBJ(nvidia) {
|
OBJ(nvidia) {
|
||||||
int hol = (strcmp((char*)&obj->data.nvidia.arg, "gpufreq")) ? 1 : 0;
|
int value = get_nvidia_value(obj->data.nvidia.type, display);
|
||||||
if(!(obj->data.nvidia.value = get_nvidia_value(obj->data.nvidia.type, display, hol)))
|
if(value == -1)
|
||||||
snprintf(p, p_max_size, "value unavailible");
|
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
|
else
|
||||||
spaced_print(p, p_max_size, "%*d", 4, "nvidia",
|
snprintf(p, p_max_size, "%d", value);
|
||||||
4, obj->data.nvidia.value);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* NVIDIA */
|
#endif /* NVIDIA */
|
||||||
|
|
||||||
|
@ -449,11 +449,4 @@ char *get_apm_battery_time(void);
|
|||||||
#include "hddtemp.h"
|
#include "hddtemp.h"
|
||||||
#endif /* HDDTEMP */
|
#endif /* HDDTEMP */
|
||||||
|
|
||||||
/* in nvidia.c */
|
|
||||||
#ifdef NVIDIA
|
|
||||||
|
|
||||||
int get_nvidia_value(QUERY_ID qid, Display *dpy, int highorlow);
|
|
||||||
|
|
||||||
#endif /* NVIDIA */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
42
src/nvidia.c
42
src/nvidia.c
@ -28,16 +28,44 @@
|
|||||||
|
|
||||||
#include "nvidia.h"
|
#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;
|
int tmp;
|
||||||
if(!XNVCTRLQueryAttribute(dpy, 0, 0, qid, &tmp)){
|
if(!XNVCTRLQueryAttribute(dpy, 0, 0, qid, &tmp)){
|
||||||
return 0;
|
return -1;
|
||||||
} else if (qid == NV_GPU_FREQ){
|
}
|
||||||
if (highorlow == 1)
|
/* FIXME: when are the low 2 bytes of NV_GPU_FREQ needed? */
|
||||||
|
if (qid == NV_GPU_FREQ)
|
||||||
return tmp >> 16;
|
return tmp >> 16;
|
||||||
else
|
|
||||||
return tmp & 0x0000FFFF;
|
|
||||||
} else
|
|
||||||
return tmp;
|
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;
|
||||||
|
}
|
||||||
|
12
src/nvidia.h
12
src/nvidia.h
@ -27,12 +27,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
#include <NVCtrl/NVCtrlLib.h>
|
|
||||||
|
|
||||||
#ifndef NVIDIA_CONKY_H
|
#ifndef NVIDIA_CONKY_H
|
||||||
#define NVIDIA_CONKY_H
|
#define NVIDIA_CONKY_H
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <NVCtrl/NVCtrlLib.h>
|
||||||
|
|
||||||
typedef enum _QUERY_ID {
|
typedef enum _QUERY_ID {
|
||||||
NV_TEMP = NV_CTRL_GPU_CORE_TEMPERATURE,
|
NV_TEMP = NV_CTRL_GPU_CORE_TEMPERATURE,
|
||||||
NV_TEMP_THRESHOLD = NV_CTRL_GPU_CORE_THRESHOLD,
|
NV_TEMP_THRESHOLD = NV_CTRL_GPU_CORE_THRESHOLD,
|
||||||
@ -43,9 +43,11 @@ typedef enum _QUERY_ID {
|
|||||||
|
|
||||||
struct nvidia_s {
|
struct nvidia_s {
|
||||||
int interval;
|
int interval;
|
||||||
int value;
|
int print_as_float;
|
||||||
char arg[20];
|
|
||||||
QUERY_ID type;
|
QUERY_ID type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int get_nvidia_value(QUERY_ID qid, Display *dpy);
|
||||||
|
int set_nvidia_type(struct nvidia_s *, const char *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user