Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conky with if_match and 'and'

I'm having a hard time googling and searching for what i'm trying to do because of the broad meaning of my searchable keywords.

I'm trying to modify my .conkyrc file to change the font color based on temperature which requires me to write something like:

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

I don't expect the above to work at all, i know the syntax is all wrong, but it's the easiest way for me to describe what I'm trying to accomplish

Below is an actual piece from my config where I tried to do it without 'and' or 'or' but of course, it doesn't work as I had hoped.

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

also, can I use elseif with conky?

${if_match "$test" >="113"}${color4}${elseif "$test1" <="120"}${color5}${endif}

or something like that?

like image 269
parsecpython Avatar asked Mar 28 '13 22:03

parsecpython


1 Answers

To simulate an AND you can use two nested IFs, this way:

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

(take care of the double ${endif}: if you open two IFs, you should close two IFs)

You will also be able to simulate an elseif nesting two IFs:

${if_match "$test" >="113"}${color4}\
    ${else}${if_match "$test" <="120"}${color5}${endif}\
${endif}  

(backslashes to improve readability)

like image 159
Tilt Avatar answered Oct 10 '22 23:10

Tilt