[SOLVED] CONKY & Variable CPU Color

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Jator
Level 2
Level 2
Posts: 80
Joined: Sat Mar 13, 2021 10:58 am

[SOLVED] CONKY & Variable CPU Color

Post by Jator »

Morning All,

I'm playing around with Conky and enjoying the freedom to customuie my own "desklet". One item that I'm stuck on is trying to have a the CPU cores return their numeric value color coded dependent on how high the core is being used. I found the below code searching for a solution that is supposed towork for batteries:

Code: Select all

$font${color1}Battery 1: $color${if_match ${battery_percent BAT0}<=15}${color7}${blink ${battery BAT0}}${color}${else}${if_match ${battery_percent BAT0}<=25}${color8}${battery BAT0}${else}${if_match ${battery_percent BAT0}>25}${color}${battery BAT0}${endif}${endif}${endif}, ${battery_time BAT0}${color}
I've addapted the code for one of my CPU Cores to test it out, but all I get is the first value color in the "if" statement no matter what the numeric value is.

Code: Select all

$font${color1}Core 7: $color${if_match cpu cpu7<=25}${color green}${cpu cpu7}L${color}${else}${if_match ${cpu cpu7}<=50}${color yellow}${cpu cpu7}M${else}${if_match ${cpu cpu7}>51}${color red}${cpu cpu7}H${endif}${endif}${endif},${color}
I added the 'L/M/H' to confirm that it's only hitting the first argument and not progressing to the next argument. So I can see the output show 100L in green when it should be showing 100H in red. Any suggestions?

Thanks.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
zcot
Level 9
Level 9
Posts: 2798
Joined: Wed Oct 19, 2016 6:08 pm

Re: CONKY & Variable CPU Color

Post by zcot »

the problem is right there: ${if_match cpu cpu7<=25}

Actually, look at it something like this if you want to, which is exactly the same, including the error(I only formatted it between multiple lines for a different clarity):

Code: Select all

$font${color1}Core 7: $color\
${if_match cpu cpu7<=25}${color green}${cpu cpu7}L${color}\
${else}\
${if_match ${cpu cpu7}<=50}${color yellow}${cpu cpu7}M\
${else}\
${if_match ${cpu cpu7}>51}${color red}${cpu cpu7}H\
${endif}${endif}${endif},${color}
Be sure to check what is going on with $font and $color areas. $font by itself will revert the font to the default at that marking, and the same with $color.

Good job though! :wink:
Jator
Level 2
Level 2
Posts: 80
Joined: Sat Mar 13, 2021 10:58 am

Re: CONKY & Variable CPU Color

Post by Jator »

Thanks zcot, it was there in front of me the whole time. ;)

Yeah, I need to clean up the code once I get all the tweaks finalized. Still learning the scripts. it's been about 15 years since I last did any form of script writing (html/php). Supposedly it's like riding a bike.....
User avatar
zcot
Level 9
Level 9
Posts: 2798
Joined: Wed Oct 19, 2016 6:08 pm

Re: CONKY & Variable CPU Color

Post by zcot »

Yep, oh, I know. :D You look it over and over many times and there's no way you see it, -you're like wth?! everything's right!

No problem though. ;)

I hope you do the same when I get hung up. :P
Locked

Return to “Compiz, Conky, Docks & Widgets”