1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

Fix 'nvidia with ncurses segfaults' (sf.net #3006233)

Additionally, add a nvidia_display variable. This enables the $nvidia variable to be used without
out_to_x yes (X11 support still has to be built in, you just don't have to use it).
This commit is contained in:
Pavel Labath 2010-08-13 15:05:05 +02:00
parent 14511b19ea
commit 8ff9b58c3b
6 changed files with 43 additions and 5 deletions

View File

@ -610,6 +610,16 @@
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>nvidia_display</option>
</command>
</term>
<listitem>The display that the nvidia variable will use (defaults to the value of the
display variable)
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>

View File

@ -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|http_refresh|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_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|mysql_host|mysql_port|mysql_user|mysql_password|mysql_db|net_avg_samples|no_buffers|out_to_console|out_to_http|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|http_refresh|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_text_width|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|mysql_host|mysql_port|mysql_user|mysql_password|mysql_db|net_avg_samples|no_buffers|nvidia_display|out_to_console|out_to_http|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)\>"

View File

@ -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 http_refresh 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_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval mysql_host mysql_port mysql_user mysql_password mysql_db net_avg_samples no_buffers out_to_console out_to_http 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 http_refresh 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_text_width max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval mysql_host mysql_port mysql_user mysql_password mysql_db net_avg_samples no_buffers nvidia_display out_to_console out_to_http 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

View File

@ -103,6 +103,9 @@
#ifdef BUILD_MYSQL
#include "mysql.h"
#endif /* BUILD_MYSQL */
#ifdef BUILD_NVIDIA
#include "nvidia.h"
#endif
/* check for OS and include appropriate headers */
#if defined(__linux__)
@ -2522,6 +2525,9 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2) {
font_count = -1;
}
#ifdef BUILD_NVIDIA
set_nvidia_display(NULL);
#endif
#endif /* BUILD_X11 */
free_templates();
@ -3061,6 +3067,12 @@ char load_config_file(const char *f)
disp = strdup(value);
}
}
#ifdef BUILD_NVIDIA
CONF("nvidia_display") {
if(value)
set_nvidia_display(value);
}
#endif
CONF("alignment") {
setalignment(&text_alignment, value, f, line, true);
}

View File

@ -57,9 +57,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? */
@ -113,7 +116,7 @@ void print_nvidia_value(struct text_object *obj, char *p, int p_max_size)
struct nvidia_s *nvs = static_cast<nvidia_s *>(obj->data.opaque);
if (!nvs ||
(value = get_nvidia_value(nvs->type, display)) == -1) {
(value = get_nvidia_value(nvs->type)) == -1) {
snprintf(p, p_max_size, "N/A");
return;
}
@ -131,3 +134,15 @@ void free_nvidia(struct text_object *obj)
free_and_zero(obj->data.opaque);
}
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));
}
}
}

View File

@ -35,5 +35,6 @@
int set_nvidia_type(struct text_object *, const char *);
void print_nvidia_value(struct text_object *, char *, int);
void free_nvidia(struct text_object *);
void set_nvidia_display(const char *disp);
#endif