gpt4 book ai didi

if-statement - 带有 if_match 和 'and' 的 conky

转载 作者:行者123 更新时间:2023-12-04 05:12:15 25 4
gpt4 key购买 nike

由于可搜索关键字的广泛含义,我很难在谷歌上搜索和搜索我想要做的事情。

我正在尝试修改我的 .conkyrc 文件以根据温度更改字体颜色,这需要我编写如下内容:

if [ $test >="50" and $test <="60"];

我根本不希望上述内容起作用,我知道语法都是错误的,但这是我描述我想要完成的事情的最简单方法

下面是我的配置中的一个实际部分,我尝试在没有“和”或“或”的情况下进行操作,但当然,它并没有像我希望的那样工作。
${goto 45}${if_match "${platform coretemp.0 temp 2}" >= "115"}${color4}${endif}${if_match "${platform coretemp.0 temp 2}" >= "125"}${color5}${endif}${if_match "${platform coretemp.0 temp 2}" >= "145"}${color6}${endif}${if_match "${platform coretemp.0 temp 2}" >= "155"}${color7}${endif}${if_match "${platform coretemp.0 temp 2}" >= "170"}${color8}${endif}${platform coretemp.0 temp 2}°F

另外,我可以将 elseif 与 conky 一起使用吗?
${if_match "$test" >="113"}${color4}${elseif "$test1" <="120"}${color5}${endif}

或类似的东西?

最佳答案

要模拟 AND,您可以使用两个嵌套的 IF,如下所示:

${if_match ${battery_percent BAT0} <= 60}${if_match ${battery_percent BAT0} >=50} my battery is between 50 and 60 ${endif}${endif}

(注意 double ${endif} :如果打开两个 IF,则应该关闭两个 IF)

您还可以模拟嵌套两个 IF 的 elseif:
${if_match "$test" >="113"}${color4}\
${else}${if_match "$test" <="120"}${color5}${endif}\
${endif}

(反斜杠以提高可读性)

关于if-statement - 带有 if_match 和 'and' 的 conky,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15692990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com