mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-15 09:44:04 +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:
parent
472a80be90
commit
252376912f
@ -563,6 +563,16 @@
|
|||||||
|
|
||||||
<para /></listitem>
|
<para /></listitem>
|
||||||
</varlistentry>
|
</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>
|
<varlistentry>
|
||||||
<term>
|
<term>
|
||||||
<command>
|
<command>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
|
syntax "conky" "(\.*conkyrc.*$|conky.conf)"
|
||||||
|
|
||||||
## Configuration items
|
## 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
|
## 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)\>"
|
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)\>"
|
||||||
|
@ -12,7 +12,7 @@ endif
|
|||||||
|
|
||||||
syn region ConkyrcComment start=/^\s*#/ end=/$/
|
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
|
syn keyword ConkyrcConstant
|
||||||
\ above
|
\ above
|
||||||
|
11
src/conky.c
11
src/conky.c
@ -2300,7 +2300,7 @@ void generate_text_internal(char *p, int p_max_size,
|
|||||||
}
|
}
|
||||||
#ifdef NVIDIA
|
#ifdef NVIDIA
|
||||||
OBJ(nvidia) {
|
OBJ(nvidia) {
|
||||||
print_nvidia_value(obj, display, p, p_max_size);
|
print_nvidia_value(obj, p, p_max_size);
|
||||||
}
|
}
|
||||||
#endif /* NVIDIA */
|
#endif /* NVIDIA */
|
||||||
#ifdef APCUPSD
|
#ifdef APCUPSD
|
||||||
@ -4055,6 +4055,9 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2) {
|
|||||||
font_count = -1;
|
font_count = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NVIDIA
|
||||||
|
set_nvidia_display(NULL);
|
||||||
|
#endif
|
||||||
#endif /* X11 */
|
#endif /* X11 */
|
||||||
|
|
||||||
free_templates();
|
free_templates();
|
||||||
@ -4602,6 +4605,12 @@ char load_config_file(const char *f)
|
|||||||
disp = strdup(value);
|
disp = strdup(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef NVIDIA
|
||||||
|
CONF("nvidia_display") {
|
||||||
|
if(value)
|
||||||
|
set_nvidia_display(value);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
CONF("alignment") {
|
CONF("alignment") {
|
||||||
setalignment(&text_alignment, window.type, value, f, line, 1);
|
setalignment(&text_alignment, window.type, value, f, line, 1);
|
||||||
}
|
}
|
||||||
|
23
src/nvidia.c
23
src/nvidia.c
@ -56,9 +56,12 @@ struct nvidia_s {
|
|||||||
QUERY_ID type;
|
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;
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
/* FIXME: when are the low 2 bytes of NV_GPU_FREQ needed? */
|
/* 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;
|
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;
|
int value;
|
||||||
struct nvidia_s *nvs = obj->data.opaque;
|
struct nvidia_s *nvs = obj->data.opaque;
|
||||||
|
|
||||||
if (!nvs ||
|
if (!nvs ||
|
||||||
(value = get_nvidia_value(nvs->type, dpy)) == -1) {
|
(value = get_nvidia_value(nvs->type)) == -1) {
|
||||||
snprintf(p, p_max_size, "N/A");
|
snprintf(p, p_max_size, "N/A");
|
||||||
return;
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
int set_nvidia_type(struct text_object *, const char *);
|
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 free_nvidia(struct text_object *);
|
||||||
|
void set_nvidia_display(const char *disp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user