【问题标题】:conky with if_match and 'and'与 if_match 和 'and' 相得益彰
【发布时间】:2013-03-19 13:10:57
【问题描述】:

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

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

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

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

下面是我的配置中的一个实际部分,我试图在没有“and”或“or”的情况下这样做,但当然,它没有像我希望的那样工作。

${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}

或者类似的?

【问题讨论】:

    标签: if-statement conky


    【解决方案1】:

    要模拟 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}  
    

    (反斜杠以提高可读性)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 2012-01-29
      • 2013-03-10
      相关资源
      最近更新 更多