diff --git a/doc/config_settings.xml b/doc/config_settings.xml
index 0467ec1a..93630972 100644
--- a/doc/config_settings.xml
+++ b/doc/config_settings.xml
@@ -563,6 +563,16 @@
+
+
+
+
+
+
+ The display that the nvidia variable will use (defaults to the value of the
+ display variable)
+
+
diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc
index 8503fe66..da956f48 100644
--- a/extras/nano/conky.nanorc
+++ b/extras/nano/conky.nanorc
@@ -5,7 +5,7 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items
-color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_specials|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
+color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|lua_shutdown_hook|lua_startup_hook|mail_spool|max_port_monitor_connections|max_specials|max_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|nvidia_display|out_to_console|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|times_in_seconds|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>"
## Configuration item constants
color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|middle_middle|undecorated|yes)\>"
diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim
index c97ffae5..3bb2beb4 100644
--- a/extras/vim/syntax/conkyrc.vim
+++ b/extras/vim/syntax/conkyrc.vim
@@ -12,7 +12,7 @@ endif
syn region ConkyrcComment start=/^\s*#/ end=/$/
-syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_specials max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
+syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load lua_shutdown_hook lua_startup_hook mail_spool max_port_monitor_connections max_specials max_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers nvidia_display out_to_console out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size times_in_seconds top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont
syn keyword ConkyrcConstant
\ above
diff --git a/src/conky.c b/src/conky.c
index c8c55e79..31441722 100644
--- a/src/conky.c
+++ b/src/conky.c
@@ -2300,7 +2300,7 @@ void generate_text_internal(char *p, int p_max_size,
}
#ifdef NVIDIA
OBJ(nvidia) {
- print_nvidia_value(obj, display, p, p_max_size);
+ print_nvidia_value(obj, p, p_max_size);
}
#endif /* NVIDIA */
#ifdef APCUPSD
@@ -4055,6 +4055,9 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2) {
font_count = -1;
}
+#ifdef NVIDIA
+ set_nvidia_display(NULL);
+#endif
#endif /* X11 */
free_templates();
@@ -4602,6 +4605,12 @@ char load_config_file(const char *f)
disp = strdup(value);
}
}
+#ifdef NVIDIA
+ CONF("nvidia_display") {
+ if(value)
+ set_nvidia_display(value);
+ }
+#endif
CONF("alignment") {
setalignment(&text_alignment, window.type, value, f, line, 1);
}
diff --git a/src/nvidia.c b/src/nvidia.c
index c6c94a91..8a6423eb 100644
--- a/src/nvidia.c
+++ b/src/nvidia.c
@@ -56,9 +56,12 @@ struct nvidia_s {
QUERY_ID type;
};
-static int get_nvidia_value(QUERY_ID qid, Display *dpy){
+static Display *nvdisplay;
+
+static int get_nvidia_value(QUERY_ID qid){
int tmp;
- if(!XNVCTRLQueryAttribute(dpy, 0, 0, nvidia_query_to_attr[qid], &tmp)){
+ Display *dpy = nvdisplay ? nvdisplay : display;
+ if(!dpy || !XNVCTRLQueryAttribute(dpy, 0, 0, nvidia_query_to_attr[qid], &tmp)){
return -1;
}
/* FIXME: when are the low 2 bytes of NV_GPU_FREQ needed? */
@@ -105,13 +108,13 @@ int set_nvidia_type(struct text_object *obj, const char *arg)
return 0;
}
-void print_nvidia_value(struct text_object *obj, Display *dpy, char *p, int p_max_size)
+void print_nvidia_value(struct text_object *obj, char *p, int p_max_size)
{
int value;
struct nvidia_s *nvs = obj->data.opaque;
if (!nvs ||
- (value = get_nvidia_value(nvs->type, dpy)) == -1) {
+ (value = get_nvidia_value(nvs->type)) == -1) {
snprintf(p, p_max_size, "N/A");
return;
}
@@ -132,3 +135,15 @@ void free_nvidia(struct text_object *obj)
}
}
+void set_nvidia_display(const char *disp)
+{
+ if(nvdisplay) {
+ XCloseDisplay(nvdisplay);
+ nvdisplay = NULL;
+ }
+ if(disp) {
+ if ((nvdisplay = XOpenDisplay(disp)) == NULL) {
+ CRIT_ERR(NULL, NULL, "can't open nvidia display: %s", XDisplayName(disp));
+ }
+ }
+}
diff --git a/src/nvidia.h b/src/nvidia.h
index 0bca85a7..41525dc6 100644
--- a/src/nvidia.h
+++ b/src/nvidia.h
@@ -35,7 +35,8 @@
#include
int set_nvidia_type(struct text_object *, const char *);
-void print_nvidia_value(struct text_object *, Display *, char *, int);
+void print_nvidia_value(struct text_object *, char *, int);
void free_nvidia(struct text_object *);
+void set_nvidia_display(const char *disp);
#endif