1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-25 20:11:11 +00:00

Added alias configfile setting

This patch is written by a anonymous author, see patch on sf.net
id #2663691 . I changed it a bit so that it can't overwrite
existing environment variables and updated the docs and syntaxfiles
This commit is contained in:
Nikolas Garofil 2009-03-07 15:12:09 +01:00
parent ecabc1a29b
commit d1baa243a8
7 changed files with 74 additions and 28 deletions

View File

@ -1,3 +1,7 @@
2009-03-07
* Added alias patch ( sf.net id #2663691 ) changed it to prevent it from
overwriting existing environment variables and updated docs, syntaxfiles, ...
2009-03-01 2009-03-01
* Added if_updatenr * Added if_updatenr
* Rewrite human_readable() to minimise amount of padding * Rewrite human_readable() to minimise amount of padding

10
README
View File

@ -155,6 +155,16 @@ conky(1) conky(1)
You might want to copy it to $HOME/.conkyrc and then start modifying You might want to copy it to $HOME/.conkyrc and then start modifying
it. Other configs can be found at http://conky.sf.net/ it. Other configs can be found at http://conky.sf.net/
1malias0m
Use this to create aliases of variables. The first argument is
the new name, the second the old name, and the other arguments
are passed on to the variable. Example: If you want to use $alpha
instead of ${beta gamma delta} then you have to write the following:
alias alpha beta gamma delta . PS: Instead of creating an alias
in the config you can also use environment variables. Example:
Start conky like this: alpha="beta gamma delta" conky
1malignment0m 1malignment0m
Aligned position on screen, may be top_left, top_right, top_mid Aligned position on screen, may be top_left, top_right, top_mid
dle, bottom_left, bottom_right, bottom_middle, middle_left, mid dle, bottom_left, bottom_right, bottom_middle, middle_left, mid

View File

@ -1,4 +1,11 @@
<variablelist> <variablelist>
<varlistentry>
<term><command><option>alias</option></command></term>
<listitem>
Use this to create aliases of variables. The first argument is the new name, the second the old name, and the other arguments are passed on to the variable. Example: If you want to use $alpha instead of ${beta gamma delta} then you have to write the following: alias alpha beta gamma delta . PS: Instead of creating an alias in the config you can also use environment variables. Example: Start conky like this: alpha="beta gamma delta" conky
<para></para></listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><command><option>alignment</option></command></term> <term><command><option>alignment</option></command></term>
<listitem> <listitem>

View File

@ -145,6 +145,10 @@ and you can find the sample config file there (/etc/conky/conky.conf).
.PP .PP
You might want to copy it to $HOME/.conkyrc and then start modifying it. You might want to copy it to $HOME/.conkyrc and then start modifying it.
Other configs can be found at http://conky.sf.net/ Other configs can be found at http://conky.sf.net/
.TP
\fB\*(T<\fBalias\fR\*(T>\fR
Use this to create aliases of variables. The first argument is the new name, the second the old name, and the other arguments are passed on to the variable. Example: If you want to use $alpha instead of ${beta gamma delta} then you have to write the following: alias alpha beta gamma delta . PS: Instead of creating an alias in the config you can also use environment variables. Example: Start conky like this: alpha="beta gamma delta" conky
.TP .TP
\fB\*(T<\fBalignment\fR\*(T>\fR \fB\*(T<\fBalignment\fR\*(T>\fR
Aligned position on screen, may be top_left, top_right, top_middle, bottom_left, bottom_right, bottom_middle, middle_left, middle_right, or none (also can be abreviated as tl, tr, tm, bl, br, bm, ml, mr) Aligned position on screen, may be top_left, top_right, top_middle, bottom_left, bottom_right, bottom_middle, middle_left, middle_right, or none (also can be abreviated as tl, tr, tm, bl, br, bm, ml, mr)

View File

@ -5,7 +5,7 @@
syntax "conky" "(\.*conkyrc.*$|conky.conf)" syntax "conky" "(\.*conkyrc.*$|conky.conf)"
## Configuration items ## Configuration items
color green "\<(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|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_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|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 ## 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)\>" 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)\>"

View File

@ -13,6 +13,7 @@ endif
syn region ConkyrcComment start=/^\s*#/ end=/$/ syn region ConkyrcComment start=/^\s*#/ end=/$/
syn keyword ConkyrcSetting syn keyword ConkyrcSetting
\ alias
\ alignment \ alignment
\ background \ background
\ show_graph_scale \ show_graph_scale

View File

@ -2795,39 +2795,40 @@ static int extract_variable_text_internal(struct text_object *retval, const char
s = p; s = p;
var = getenv(buf); var = getenv(buf);
if (var) {
strncpy(buf, var, 255);
}
/* if variable wasn't found in environment, use some special */ char *tmp_p;
if (!var) { char *arg = 0;
char *tmp_p;
char *arg = 0;
/* split arg */ /* split arg */
if (strchr(buf, ' ')) { if (strchr(buf, ' ')) {
arg = strchr(buf, ' '); arg = strchr(buf, ' ');
*arg = '\0'; *arg = '\0';
arg++;
while (isspace((int) *arg)) {
arg++; arg++;
while (isspace((int) *arg)) {
arg++;
}
if (!*arg) {
arg = 0;
}
} }
if (!*arg) {
/* lowercase variable name */ arg = 0;
tmp_p = buf;
while (*tmp_p) {
*tmp_p = tolower(*tmp_p);
tmp_p++;
}
obj = construct_text_object(buf, arg,
line, allow_threaded,
&ifblock_opaque);
if (obj != NULL) {
append_object(retval, obj);
} }
} }
/* lowercase variable name */
tmp_p = buf;
while (*tmp_p) {
*tmp_p = tolower(*tmp_p);
tmp_p++;
}
obj = construct_text_object(buf, arg,
line, allow_threaded,
&ifblock_opaque);
if (obj != NULL) {
append_object(retval, obj);
}
continue; continue;
} else { } else {
obj = create_plain_text("$"); obj = create_plain_text("$");
@ -7230,6 +7231,25 @@ static void load_config_file(const char *f)
} }
} }
CONF("alias") {
if (value) {
char *skey, *svalue, *oldvalue;
if (sscanf(value, "%a[0-9a-zA-Z_] %a[^\n]", &skey, &svalue) == 2) {
oldvalue = getenv(skey);
if(oldvalue == NULL) {
setenv(skey, svalue, 0);
free(skey);
free(svalue);
}
//PS: Don't free oldvalue, it's the real envvar, not a copy
} else {
CONF_ERR;
}
} else {
CONF_ERR;
}
}
else { else {
ERR("%s: %d: no such configuration: '%s'", f, line, name); ERR("%s: %d: no such configuration: '%s'", f, line, name);
} }