Added default_bar/graph/gauge_size config options (thanks wire64 for the idea)
authorBrenden Matthews <brenden@rty.ca>
Thu, 9 Apr 2009 22:00:40 +0000 (16:00 -0600)
committerBrenden Matthews <brenden@rty.ca>
Thu, 9 Apr 2009 22:00:40 +0000 (16:00 -0600)
ChangeLog
README
doc/config_settings.xml
doc/conky.1
extras/nano/conky.nanorc
extras/vim/syntax/conkyrc.vim
src/conky.c
src/specials.c
src/specials.h

index de8aef0..65a7231 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
        * Fix broken xmms2 compilation (thanks fusetak)
        * Minor fix for fs_used_perc, fs_free and fs_free_perc (thanks
        lightpriest)
+       * Added default_bar/graph/gauge_size config options (thanks wire64 for the
+       idea)
 
 2009-03-28
        * Applied FreeBSD patches (thanks Nikos)
diff --git a/README b/README
index d515704..773662e 100644 (file)
--- a/README
+++ b/README
@@ -199,6 +199,24 @@ conky(1)                                                              conky(1)
               combined.
 
 
+       \e[1mdefault_bar_size\e[0m
+              Specify  a  default  width  and  height  for bars. Example: 'de‐
+              fault_bar_size 0 6'. This is particularly useful for execbar and
+              execibar as they do not take size arguments
+
+
+       \e[1mdefault_graph_size\e[0m
+              Specify  a  default  width  and height for graphs. Example: 'de‐
+              fault_graph_size 0 25'. This is particularly  useful  for  exec‐
+              graph and execigraph as they do not take size arguments
+
+
+       \e[1mdefault_gauge_size\e[0m
+              Specify  a  default  width  and height for gauges. Example: 'de‐
+              fault_gauge_size 25 25'. This is particularly useful  for  exec‐
+              gauge and execigauge as they do not take size arguments
+
+
        \e[1mdefault_color\e[0m
               Default color and border color
 
index dfde685..52ae916 100644 (file)
        </varlistentry>
 
        <varlistentry>
+               <term><command><option>default_bar_size</option></command></term>
+               <listitem>
+                       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
+                       <para></para></listitem>
+       </varlistentry>
+
+       <varlistentry>
+               <term><command><option>default_graph_size</option></command></term>
+               <listitem>
+                       Specify a default width and height for graphs.  Example: 'default_graph_size 0 25'.  This is particularly useful for execgraph and execigraph as they do not take size arguments
+                       <para></para></listitem>
+       </varlistentry>
+
+       <varlistentry>
+               <term><command><option>default_gauge_size</option></command></term>
+               <listitem>
+                       Specify a default width and height for gauges.  Example: 'default_gauge_size 25 25'.  This is particularly useful for execgauge and execigauge as they do not take size arguments
+                       <para></para></listitem>
+       </varlistentry>
+
+       <varlistentry>
                <term><command><option>default_color</option></command></term>
                <listitem>
                        Default color and border color
index 71f089a..02265b7 100644 (file)
@@ -178,6 +178,18 @@ The number of samples to average for CPU monitoring
 If true, cpu in top will show usage of one processor's power. If false, cpu in top will show the usage of all processors' power combined.
 
 .TP 
+\fB\*(T<\fBdefault_bar_size\fR\*(T>\fR
+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
+
+.TP 
+\fB\*(T<\fBdefault_graph_size\fR\*(T>\fR
+Specify a default width and height for graphs. Example: 'default_graph_size 0 25'. This is particularly useful for execgraph and execigraph as they do not take size arguments
+
+.TP 
+\fB\*(T<\fBdefault_gauge_size\fR\*(T>\fR
+Specify a default width and height for gauges. Example: 'default_gauge_size 25 25'. This is particularly useful for execgauge and execigauge as they do not take size arguments
+
+.TP 
 \fB\*(T<\fBdefault_color\fR\*(T>\fR
 Default color and border color
 
index d3488d6..761c499 100644 (file)
@@ -5,7 +5,7 @@
 syntax "conky" "(\.*conkyrc.*$|conky.conf)"
 
 ## Configuration items
-color green "\<(alias|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|out_to_x|extra_newline|overwrite_file|append_file|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 "\<(alias|alignment|background|show_graph_range|show_graph_scale|border_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|default_bar_size|default_gauge_size|default_graph_size|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|out_to_x|extra_newline|overwrite_file|append_file|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)\>"
index e744636..78eba75 100644 (file)
@@ -30,6 +30,9 @@ syn keyword ConkyrcSetting
                        \ color7
                        \ color8
                        \ color9
+                       \ default_bar_size
+                       \ default_gauge_size
+                       \ default_graph_size
                        \ default_color
                        \ default_shade_color
                        \ default_shadecolor
index e5a9f7f..badc667 100644 (file)
@@ -6494,6 +6494,7 @@ static void X11_initialisation(void)
 static void load_config_file(const char *f)
 {
 #define CONF_ERR ERR("%s: %d: config file error", f, line)
+#define CONF_ERR2(a) ERR("%s: %d: config file error: %s", f, line, a)
        int line = 0;
        FILE *fp;
 
@@ -6670,6 +6671,45 @@ static void 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')")
+                       }
+               }
+               CONF("default_graph_size") {
+                       char err = 0;
+                       if (value) {
+                               if (sscanf(value, "%d %d", &default_graph_width, &default_graph_height) != 2) {
+                                       err = 1;
+                               }
+                       } else {
+                               err = 1;
+                       }
+                       if (err) {
+                               CONF_ERR2("default_graph_size takes 2 integer arguments (ie. 'default_graph_size 0 6')")
+                       }
+               }
+               CONF("default_gauge_size") {
+                       char err = 0;
+                       if (value) {
+                               if (sscanf(value, "%d %d", &default_gauge_width, &default_gauge_height) != 2) {
+                                       err = 1;
+                               }
+                       } else {
+                               err = 1;
+                       }
+                       if (err) {
+                               CONF_ERR2("default_gauge_size takes 2 integer arguments (ie. 'default_gauge_size 0 6')")
+                       }
+               }
 #ifdef MPD
                CONF("mpd_host") {
                        if (value) {
index a79500d..3cf2af9 100644 (file)
@@ -42,6 +42,10 @@ struct special_t *specials = NULL;
 
 unsigned int special_count;
 
+int default_bar_width = 0, default_bar_height = 6;
+int default_graph_width = 25, default_graph_height = 25;
+int default_gauge_width = 0, default_gauge_height = 25;
+
 /*
  * Scanning arguments to various special text objects
  */
@@ -49,8 +53,8 @@ unsigned int special_count;
 const char *scan_gauge(const char *args, int *w, int *h)
 {
        /*width and height*/
-       *w = 25;
-       *h = 25;
+       *w = default_gauge_width;
+       *h = default_gauge_height;
 
        /* gauge's argument is either height or height,width */
        if (args) {
@@ -69,8 +73,8 @@ const char *scan_gauge(const char *args, int *w, int *h)
 const char *scan_bar(const char *args, int *w, int *h)
 {
        /* zero width means all space that is available */
-       *w = 0;
-       *h = 6;
+       *w = default_bar_width;
+       *h = default_bar_height;
        /* bar's argument is either height or height,width */
        if (args) {
                int n = 0;
@@ -102,8 +106,8 @@ char *scan_graph(const char *args, int *w, int *h,
        buf[0] = 0;
 
        /* zero width means all space that is available */
-       *w = 0;
-       *h = 25;
+       *w = default_graph_width;
+       *h = default_graph_height;
        *first_colour = 0;
        *last_colour = 0;
        *scale = 0;
index 441999e..6736ade 100644 (file)
@@ -76,6 +76,13 @@ struct special_t {
 extern struct special_t *specials;
 extern unsigned int special_count;
 
+extern int default_bar_width;
+extern int default_bar_height;
+extern int default_graph_width;
+extern int default_graph_height;
+extern int default_gauge_width;
+extern int default_gauge_height;
+
 /* max number of specials allowed (TODO: use linked list instead) */
 extern unsigned int max_specials;