Note that you will need execp or execpi to do the above as exec and execi do not parse the output of the script
execp: Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch. This differs from $exec in that it parses the output of the command, so you can insert things like ${color red}hi!${color} in your script and have it correctly parsed by Conky. Caveats: Conky parses and evaluates the output of $execp every time Conky loops, and then destroys all the objects. If you try to use anything like $execi within an $execp statement, it will functionally run at the same interval that the $execp statement runs, as it is created and destroyed at every interval.
This also works with simply cat'ing a file such as:
${execpi 15 cat /path/to/file.log}
Here's an alternate line #4 for your script which will even work if your color file contains some garbage (e. g. control characters) beyond the 1st line for some reason:
awk 'NR==1{print}' color-file
. I'd always avoidcat
in these cases because it is always risky to blindly assume the file will only contain one neat line. A blank line following the first line might already induce problems. – syntaxerror – 2014-10-11T13:08:36.690You're right @syntaxerror I edited the answer and also updated the bash-script – micke – 2014-10-11T15:28:56.403
Looks pretty good now, thanks for the quick update ... except that I'm still not sure that this will work in Conky without the first
$
in theecho
line being escaped with a backslash. Conky is always picky about these things.:) Even though I might be wrong. – syntaxerror – 2014-10-11T17:38:17.207Nah, it's cool. No need for escaping inside single quotes. – micke – 2014-10-11T21:24:48.727