1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-30 10:38:36 +00:00

make out_to_console/stderr lua settings

This commit is contained in:
Pavel Labath 2010-04-30 19:06:17 +02:00
parent c31f27fe92
commit dfc9efa3cc
2 changed files with 22 additions and 18 deletions

View File

@ -160,6 +160,10 @@ static conky::simple_config_setting<spacer_state> use_spacer("use_spacer", NO_SP
static conky::simple_config_setting<bool> short_units("short_units", false, true); static conky::simple_config_setting<bool> short_units("short_units", false, true);
static conky::simple_config_setting<bool> format_human_readable("format_human_readable", static conky::simple_config_setting<bool> format_human_readable("format_human_readable",
true, true); true, true);
static conky::simple_config_setting<bool> out_to_stdout("out_to_console", false, false);
static conky::simple_config_setting<bool> out_to_stderr("out_to_stderr", false, false);
int top_cpu, top_mem, top_time; int top_cpu, top_mem, top_time;
#ifdef BUILD_IOSTATS #ifdef BUILD_IOSTATS
int top_io; int top_io;
@ -1163,12 +1167,12 @@ static void draw_string(const char *s)
s_with_newlines[i] = '\n'; s_with_newlines[i] = '\n';
} }
} }
if ((output_methods & TO_STDOUT) && draw_mode == FG) { if (out_to_stdout.get(*state) && draw_mode == FG) {
printf("%s\n", s_with_newlines); printf("%s\n", s_with_newlines);
if (extra_newline.get(*state)) fputc('\n', stdout); if (extra_newline.get(*state)) fputc('\n', stdout);
fflush(stdout); /* output immediately, don't buffer */ fflush(stdout); /* output immediately, don't buffer */
} }
if ((output_methods & TO_STDERR) && draw_mode == FG) { if (out_to_stderr.get(*state) && draw_mode == FG) {
fprintf(stderr, "%s\n", s_with_newlines); fprintf(stderr, "%s\n", s_with_newlines);
fflush(stderr); /* output immediately, don't buffer */ fflush(stderr); /* output immediately, don't buffer */
} }
@ -2571,7 +2575,8 @@ static void set_default_configurations(void)
state->pushboolean(true); state->pushboolean(true);
out_to_x.lua_set(*state); out_to_x.lua_set(*state);
#else #else
output_methods = TO_STDOUT; state->pushboolean(true);
out_to_stdout.lua_set(*state);
#endif #endif
#ifdef BUILD_X11 #ifdef BUILD_X11
set_first_font("6x10"); set_first_font("6x10");
@ -2942,17 +2947,6 @@ char load_config_file(const char *f)
CONF("max_text_width") { CONF("max_text_width") {
max_text_width = atoi(value); max_text_width = atoi(value);
} }
CONF("out_to_console") {
if(string_to_bool(value)) {
output_methods |= TO_STDOUT;
} else {
output_methods &= ~TO_STDOUT;
}
}
CONF("out_to_stderr") {
if(string_to_bool(value))
output_methods |= TO_STDERR;
}
#ifdef BUILD_NCURSES #ifdef BUILD_NCURSES
CONF("out_to_ncurses") { CONF("out_to_ncurses") {
if(string_to_bool(value)) { if(string_to_bool(value)) {
@ -3277,9 +3271,14 @@ char load_config_file(const char *f)
endwin(); endwin();
} }
#endif /* BUILD_X11 */ #endif /* BUILD_X11 */
if ((output_methods & (TO_STDOUT | TO_STDERR)) && (output_methods & TO_NCURSES)) { if ((out_to_stdout.get(*state) || out_to_stderr.get(*state))
&& (output_methods & TO_NCURSES)) {
NORM_ERR("out_to_ncurses conflicts with out_to_console and out_to_stderr, disabling the later ones"); NORM_ERR("out_to_ncurses conflicts with out_to_console and out_to_stderr, disabling the later ones");
output_methods &= ~(TO_STDOUT | TO_STDERR); // XXX: this will need some rethinking
state->pushboolean(false);
out_to_stdout.lua_set(*state);
state->pushboolean(false);
out_to_stderr.lua_set(*state);
} }
#endif /* BUILD_NCURSES */ #endif /* BUILD_NCURSES */
return TRUE; return TRUE;
@ -3445,7 +3444,13 @@ void initialisation(int argc, char **argv) {
global_text = strndup(optarg, max_user_text); global_text = strndup(optarg, max_user_text);
convert_escapes(global_text); convert_escapes(global_text);
total_run_times = 1; total_run_times = 1;
output_methods = TO_STDOUT;
state->pushboolean(true);
out_to_stdout.lua_set(*state);
#ifdef BUILD_X11
state->pushboolean(false);
out_to_x.lua_set(*state);
#endif
for_scripts = true; for_scripts = true;
} }
} }

View File

@ -321,7 +321,6 @@ extern unsigned int max_user_text;
/* path to config file */ /* path to config file */
extern std::string current_config; extern std::string current_config;
#define TO_STDOUT 2
#define TO_STDERR 4 #define TO_STDERR 4
#define OVERWRITE_FILE 8 #define OVERWRITE_FILE 8
#define APPEND_FILE 16 #define APPEND_FILE 16