Im trying to chech if the file exists in conky using ${if_existing ..} as follows:
${if_existing /home/stanislav/.cache/yandexweather/bkn_n.png}YES \
${else}NO
${endif}\
And this works perfectly. However how can I use ${if_existing ..} statement with an output of another command? For Example:
${if_existing echo "~/.cache/yandexweather/"$(python ~/.cache/yandexweather/yw_script.py -image_0)}YES \
${else}NO
${endif}\
The latter doesnt work
You could use ${eval ...}
to have the shell command calculated first, then having the ${if_...}
part parsed. For example,
${eval $${if_existing ${execi 10 echo "myfile"}}\
YES $${else} NO $${endif} }
Inside the eval, the if..
else
and endif
parts are made to not work by doubling the $
to $$
. However, the ${execi
part runs and executes the shell command (echo ...
) every 10 seconds (choose a big value if your expression will never change).
After the execi has returned the string (myfile
, in this example), the resulting command is parsed again. Each $$
has been evaluated to $
, so we have:
${if_existing myfile} YES ${else} NO ${endif}