From 4c25a9680e0bdcf964f7f37b45ff1a5ed13ad2ac Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Tue, 10 Feb 2009 09:43:20 +0100 Subject: [PATCH] Added output_to_stderr --- ChangeLog | 3 +++ data/conky.conf | 1 + doc/config_settings.xml | 8 ++++++++ doc/conky.1 | 4 ++++ doc/conky.conf | 3 +++ extras/nano/conky.nanorc | 2 +- extras/vim/syntax/conkyrc.vim | 1 + src/conky.c | 8 ++++++++ 8 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 5aa2bb3f..11e08191 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-02-10 + * Added output_to_stderr + 2009-02-08 * Refactor top code, add top_time to sort by process cpu time (thanks sohalt). diff --git a/data/conky.conf b/data/conky.conf index d61f9ef4..ddfe6083 100644 --- a/data/conky.conf +++ b/data/conky.conf @@ -41,6 +41,7 @@ minimum_size 5 5 net_avg_samples 2 no_buffers yes out_to_console no +out_to_stderr no own_window yes own_window_class Conky own_window_type normal diff --git a/doc/config_settings.xml b/doc/config_settings.xml index 5ab6591c..7e59df20 100644 --- a/doc/config_settings.xml +++ b/doc/config_settings.xml @@ -315,6 +315,14 @@ + + + + + Print text to stderr. + + + diff --git a/doc/conky.1 b/doc/conky.1 index f7a5f3dd..c3f24b9d 100644 --- a/doc/conky.1 +++ b/doc/conky.1 @@ -322,6 +322,10 @@ of window can be useful for certain situations. \fB\*(T<\fBout_to_console\fR\*(T>\fR Print text to stdout. +.TP +\fB\*(T<\fBout_to_stderr\fR\*(T>\fR +Print text to stderr. + .TP \fB\*(T<\fBpad_percents\fR\*(T>\fR Pad percentages to this many decimals (0 = no padding) diff --git a/doc/conky.conf b/doc/conky.conf index 2e035424..b5843d2a 100644 --- a/doc/conky.conf +++ b/doc/conky.conf @@ -28,6 +28,9 @@ xftalpha 0.8 # Print everything to stdout? # out_to_console no +# ... or maybe to stderr ? +# out_to_stderr no + # MPD host/port # mpd_host localhost # mpd_port 6600 diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index ddee3944..e6362fac 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|background|show_graph_range|show_graph_scale|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|default_color|default_shade_color|default_shadecolor|default_outline_color|default_outlinecolor|imap|pop3|mpd_host|mpd_port|mpd_password|music_player_interval|sensor_device|cpu_avg_samples|net_avg_samples|double_buffer|override_utf8_locale|draw_borders|draw_graph_borders|draw_shades|draw_outline|out_to_console|use_spacer|use_xft|font|xftalpha|xftfont|use_xft|gap_x|gap_y|mail_spool|minimum_size|maximum_width|no_buffers|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|top_cpu_separate|short_units|pad_percents|own_window|own_window_class|own_window_title|own_window_transparent|own_window_colour|own_window_hints|own_window_type|stippled_borders|temp1|temp2|update_interval|total_run_times|uppercase|max_specials|max_user_text|text_buffer_size|max_port_monitor_connections)\>" +color green "\<(alignment|background|show_graph_range|show_graph_scale|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|default_color|default_shade_color|default_shadecolor|default_outline_color|default_outlinecolor|imap|pop3|mpd_host|mpd_port|mpd_password|music_player_interval|sensor_device|cpu_avg_samples|net_avg_samples|double_buffer|override_utf8_locale|draw_borders|draw_graph_borders|draw_shades|draw_outline|out_to_console|out_to_stderr|use_spacer|use_xft|font|xftalpha|xftfont|use_xft|gap_x|gap_y|mail_spool|minimum_size|maximum_width|no_buffers|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|top_cpu_separate|short_units|pad_percents|own_window|own_window_class|own_window_title|own_window_transparent|own_window_colour|own_window_hints|own_window_type|stippled_borders|temp1|temp2|update_interval|total_run_times|uppercase|max_specials|max_user_text|text_buffer_size|max_port_monitor_connections)\>" ## 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|undecorated|yes)\>" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index b3a93e55..311770f4 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -50,6 +50,7 @@ syn keyword ConkyrcSetting \ draw_shades \ draw_outline \ out_to_console + \ out_to_stderr \ use_spacer \ use_xft \ font diff --git a/src/conky.c b/src/conky.c index 120c32eb..0027b3fd 100644 --- a/src/conky.c +++ b/src/conky.c @@ -128,6 +128,7 @@ enum { int top_cpu, top_mem, top_time; #define TO_X 1 #define TO_STDOUT 2 +#define TO_STDERR 4 static int output_methods; static volatile int g_signal_pending; /* Update interval */ @@ -5840,6 +5841,10 @@ static void draw_string(const char *s) printf("%s\n", s); fflush(stdout); /* output immediately, don't buffer */ } + if ((output_methods & TO_STDERR) && draw_mode == FG) { + fprintf(stderr, "%s\n", s); + fflush(stderr); /* output immediately, don't buffer */ + } memset(tmpstring1, 0, text_buffer_size); memset(tmpstring2, 0, text_buffer_size); strncpy(tmpstring1, s, text_buffer_size - 1); @@ -7476,6 +7481,9 @@ static void load_config_file(const char *f) CONF("out_to_console") { if(string_to_bool(value)) output_methods |= TO_STDOUT; } + CONF("out_to_stderr") { + if(string_to_bool(value)) output_methods |= TO_STDERR; + } CONF("use_spacer") { if (value) { if (strcasecmp(value, "left") == EQUAL) {