From 34a34693d7ed0afa63e997558dd9791f8070578c Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 26 Aug 2010 16:33:13 +0200 Subject: [PATCH] Make default_bar_{width,height} lua settings --- doc/config_settings.xml | 18 +++++++++++++----- extras/nano/conky.nanorc | 2 +- extras/vim/syntax/conkyrc.vim | 2 +- src/conky.cc | 13 ------------- src/specials.cc | 11 ++++++++--- src/specials.h | 2 -- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/doc/config_settings.xml b/doc/config_settings.xml index 6897e41c..e5bdf51e 100644 --- a/doc/config_settings.xml +++ b/doc/config_settings.xml @@ -97,13 +97,21 @@ - + - Specify a default width and height for bars. - Example: 'default_bar_size 0 6'. This is particularly - useful for execbar and execibar as they do not take size - arguments. + Specify a default height for bars. This is particularly useful for execbar and + execibar as they do not take size arguments. + + + + + + + + + Specify a default width for bars. This is particularly useful for execbar and + execibar as they do not take size arguments. diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index 89527d8f..1f9f427e 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|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)\>" +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_height|default_bar_width|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)\>" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index 77759501..523b1a6d 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -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 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 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_height default_bar_width 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 diff --git a/src/conky.cc b/src/conky.cc index c5bd4f56..210eedcf 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2797,19 +2797,6 @@ char load_config_file(const char *f) CONF_ERR; } } - CONF("default_bar_size") { - char err = 0; - if (value) { - if (sscanf(value, "%d %d", &default_bar_width, &default_bar_height) != 2) { - err = 1; - } - } else { - err = 1; - } - if (err) { - CONF_ERR2("default_bar_size takes 2 integer arguments (ie. 'default_bar_size 0 6')") - } - } #ifdef BUILD_X11 CONF("default_graph_size") { char err = 0; diff --git a/src/specials.cc b/src/specials.cc index b74fd573..263e876b 100644 --- a/src/specials.cc +++ b/src/specials.cc @@ -45,7 +45,12 @@ struct special_t *specials = NULL; int special_count; -int default_bar_width = 0, default_bar_height = 6; +namespace { + conky::range_config_setting default_bar_width("default_bar_width", 0, + std::numeric_limits::max(), 0, false); + conky::range_config_setting default_bar_height("default_bar_height", 0, + std::numeric_limits::max(), 6, false); +} #ifdef BUILD_X11 int default_graph_width = 0, default_graph_height = 25; #endif /* BUILD_X11 */ @@ -131,8 +136,8 @@ const char *scan_bar(struct text_object *obj, const char *args, double scale) memset(b, 0, sizeof(struct bar)); /* zero width means all space that is available */ - b->width = default_bar_width; - b->height = default_bar_height; + b->width = default_bar_width.get(*state); + b->height = default_bar_height.get(*state); if (scale) b->scale = scale; diff --git a/src/specials.h b/src/specials.h index 38b8d6ad..4e43da4d 100644 --- a/src/specials.h +++ b/src/specials.h @@ -80,8 +80,6 @@ struct special_t { extern struct special_t *specials; extern int special_count; -extern int default_bar_width; -extern int default_bar_height; #ifdef BUILD_X11 extern int default_graph_width; extern int default_graph_height;