[英]How to use if_existing statment with path string?
Im trying to chech if the file exists in conky using ${if_existing ..} as follows: 我试图使用$ {if_existing ..}检查文件是否存在于conky中,如下所示:
${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?
但是,如何在其他命令的输出中使用$ {if_existing ..}语句? 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. 您可以使用
${eval ...}
先计算shell命令,然后再分析${if_...}
部分。 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 $$
. 在eval内,通过将
$
变为$$
来使if..
else
和endif
部分不起作用。 However, the ${execi
part runs and executes the shell command ( echo ...
) every 10 seconds (choose a big value if your expression will never change). 但是,
${execi
部分每10秒运行并执行一次shell命令( echo ...
)(如果您的表达式永远不变,请选择一个大值)。
After the execi has returned the string ( myfile
, in this example), the resulting command is parsed again. execi返回字符串(在本示例中为
myfile
)后,将再次解析结果命令。 Each $$
has been evaluated to $
, so we have: 每个
$$
已被评估为$
,所以我们有:
${if_existing myfile} YES ${else} NO ${endif}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.