Added top_name_width config option.
authorBrenden Matthews <brenden@rty.ca>
Thu, 7 May 2009 23:49:32 +0000 (17:49 -0600)
committerBrenden Matthews <brenden@rty.ca>
Thu, 7 May 2009 23:49:32 +0000 (17:49 -0600)
ChangeLog
README
doc/config_settings.xml
extras/nano/conky.nanorc
extras/vim/syntax/conkyrc.vim
src/conky.c

index fc13496..259572c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2009-05-07
        * Fix occasional cpubar segfaults
+       * Added top_name_width config option
 
 2009-05-05
        * Added some completely pointless OpenMP optimizations(?)
diff --git a/README b/README
index 533d183..9b14d7e 100644 (file)
--- a/README
+++ b/README
@@ -197,6 +197,10 @@ conky(1)                                                              conky(1)
               The number of samples to average for disk I/O monitoring.
 
 
+       \e[1mtop_name_width\e[0m
+              Width for $top name value (defaults to 15 characters).
+
+
        \e[1mtop_cpu_separate\e[0m
               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
index fb69521..840a953 100644 (file)
        </varlistentry>
 
        <varlistentry>
+               <term><command><option>top_name_width</option></command></term>
+               <listitem>
+                       Width for $top name value (defaults to 15 characters).
+                       <para></para></listitem>
+       </varlistentry>
+
+       <varlistentry>
                <term><command><option>top_cpu_separate</option></command></term>
                <listitem>
                        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.
index 3ee15a6..ed4920e 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_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)\>"
+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_name_width|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 8702ea7..c43f4e4 100644 (file)
@@ -70,6 +70,7 @@ syn keyword ConkyrcSetting
                        \ minimum_size
                        \ maximum_width
                        \ no_buffers
+                       \ top_name_width
                        \ top_cpu_separate
                        \ short_units
                        \ pad_percents
index fef2555..b692bef 100644 (file)
@@ -131,6 +131,7 @@ enum {
        RIGHT_SPACER
 } use_spacer;
 int top_cpu, top_mem, top_time;
+static unsigned int top_name_width = 15;
 int output_methods;
 enum x_initialiser_state x_initialised = NO;
 static volatile int g_signal_pending;
@@ -4701,7 +4702,7 @@ static void generate_text_internal(char *p, int p_max_size,
 
                                        switch (obj->data.top.type) {
                                                case TOP_NAME:
-                                                       snprintf(p, 16, "%-15s",
+                                                       snprintf(p, top_name_width + 1, "%-*s", top_name_width,
                                                                needed[obj->data.top.num]->name);
                                                        break;
                                                case TOP_CPU:
@@ -7133,6 +7134,18 @@ static void load_config_file(const char *f)
                CONF("no_buffers") {
                        no_buffers = string_to_bool(value);
                }
+               CONF("top_name_width") {
+                       if (value) {
+                               if (sscanf(value, "%u", &top_name_width) != 1) {
+                                       CONF_ERR;
+                               }
+                       } else {
+                               CONF_ERR;
+                       }
+                       if (top_name_width >= max_user_text) {
+                               top_name_width = max_user_text - 1;
+                       }
+               }
                CONF("top_cpu_separate") {
                        cpu_separate = string_to_bool(value);
                }