Using soft links
In your ~/.conkyrc
file, add the line:
$
After the qdbus
line in your script, add the line:
ln -sf "$(cat ~/.config/openbox/conky/image)" /tmp/conky.jpg
This ln
command updates the link file /tmp/conky.jpg
to point to whatever image file name is in the ~/.config/openbox/conky/image
file.
To get the behavior that you want, you may want to experiment with two flags on the conky image
line: -n
tells conky not to cache the image while -f interval
to specifies conky's cache flush interval for that image.
Using awk
To summarize, the name of your image file is in ~/.config/openbox/conky/image
and you want to transfer it to your ~/.conkyrc
file. So, after the qdbus
line in your script, add the line:
awk -v "img=$(cat ~/.config/openbox/conky/image)" '/image/ 1' ~/.conkyrc.in >~/.conkyrc
where ~/.conkyrc.in
is your prototype conkyrc file, the one that contains the line:
$
The awk command replaces the xxxx with the name of your image file. After the awk
command is run, a new ~/.conkyrc
file is created with the correct image name.
How it works:
-v "img=$(cat ~/.config/openbox/conky/image)"
This creates an
awk
variableimg
and assigns to it the contents of~/.config/openbox/conky/image
./image/
This looks for lines containing the word
image
. For any line containing that word, the first occurrence ofxxxx
is replaced with the value of variableimg
.1
This cryptic command just tells awk to print every line it receives from the input file.
~/.conkyrc.in
This is input file, the one containing the dummy
$
Then, run:
m4 ~/.conkyrc.m4 >~/.conkyrc
m4
will recognizetranslit
andinclude
as commands that it should obey. When it sees theinclude
command, it will read your~/.config/openbox/conky/image
and include the contents. That file will likely have a trailing new line character. Thetranslit
command is there to remove that newline.m4
is a very powerful macro language that you can use to manage many parts of your conkyrc file. If you don't want to take the time to learn a new language, it is probably simpler to stick to theawk
solution.