diff --git a/src/conky.cc b/src/conky.cc index 9dbdd3ae..69fd46c5 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -163,6 +163,7 @@ static conky::simple_config_setting format_human_readable("format_human_re static conky::simple_config_setting out_to_stdout("out_to_console", false, false); static conky::simple_config_setting out_to_stderr("out_to_stderr", false, false); + int top_cpu, top_mem, top_time; #ifdef BUILD_IOSTATS int top_io; @@ -368,6 +369,43 @@ int sendanswer(void *cls, struct MHD_Connection *connection, const char *url, co if(cls || url || method || version || upload_data || upload_data_size || con_cls) {} //make compiler happy return ret; } + +class out_to_http_setting: public conky::simple_config_setting { + typedef conky::simple_config_setting Base; + +protected: + virtual void lua_setter(lua::state &l, bool init) + { + lua::stack_sentry s(l, -2); + + Base::lua_setter(l, init); + + if(init && do_convert(l, -1).first) { + httpd = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, HTTPPORT, + NULL, NULL, &sendanswer, NULL, MHD_OPTION_END); + } + + ++s; + } + + virtual void cleanup(lua::state &l) + { + lua::stack_sentry s(l, -1); + + if(do_convert(l, -1).first) { + MHD_stop_daemon(httpd); + httpd = NULL; + } + + l.pop(); + } + +public: + out_to_http_setting() + : Base("out_to_http", false, false) + {} +}; +static out_to_http_setting out_to_http; #endif #ifdef BUILD_X11 @@ -1222,7 +1260,7 @@ static void draw_string(const char *s) } #endif #ifdef BUILD_HTTP - if ((output_methods & TO_HTTP) && draw_mode == FG) { + if (out_to_http.get(*state) && draw_mode == FG) { std::string::size_type origlen = webpage.length(); webpage.append(s_with_newlines); webpage = string_replace_all(webpage, "\n", "
", origlen); @@ -1792,7 +1830,7 @@ static void draw_text(void) #define WEBPAGE_START1 "\n" #define WEBPAGE_START2 "Conky

" #define WEBPAGE_END "

" - if (output_methods & TO_HTTP) { + if (out_to_http.get(*state)) { webpage = WEBPAGE_START1; if(http_refresh.get(*state)) { webpage.append("