From Conky PitStop

Jump to: navigation, search

 Language   English   Français   

This script originally came to me shortly after hearing about the parsing execution or ‘execpi’ command in conky. I was staggered by the possibilities!

This deceptively simple script, in it’s purest form, takes the results of any program that returns a number, or can be made to, and places a conkyscript ${color} prior to the result. In application, this allows you to have temperatures displayed on your conky that pop out in bright red when they get too hot, and sit in the background at a cool blue when things are fine.

Above TEXT in your conky file define the three colors as, or similar to:

#    colours below used by colorize script
color7 lightblue
color8 yellow
color9 red

It is fairly simple to use and even modify for: Battery, HDD, CPU, GPU, and any other application you can think of. If you have differing ranges it’s simple to make copies and set up a for CPU Usage, Unread Email… whatever! I suggest using common sense naming for the scripts (like, and to help you tell which one does what.

You can use the following conky command provided you know and can modify the ‘cut’ command for the number field… or only a number is returned from the program. (in which case you can remove the grep, paste, and cut commands)

${execpi 6 sensors | grep 'Core 0' | paste -s | cut -c15-18 | xargs ~/.conky/conkyparts/} ... $color

...or you can use this line for anything that returns a temperature which will, in effect, chop off everything after the ° symbol... but you still need to know where the number starts.

${execpi 6 sensors | grep 'Core 0' | paste -s |sed 's/°/\n/'| head -n1 | cut -c15- | xargs ~/.conky/conkyparts/} ... $color

(credit to searchOne for pointing out a need for this and finding the way.)

# by Crinos512
# Usage:
#  ${execpi 6 sensors | grep 'Core 0' | paste -s | cut -c15-18 | xargs ~/.conky/conkyparts/} ... $color
# or
#  ${execpi 6 sensors | grep 'Core 0' | paste -s |sed 's/°/\n/'| head -n1 | cut -c15- | xargs ~/.conky/conkyparts/} ... $color
# Note: Assign color7, color8, and color9 to COOL, WARM, and HOT respectively
#   your .conkyrc


if [[ $1 -lt $COOL ]]
   then echo "\${color7}"$1    # COOL
elif [[ $1 -gt $WARM ]]
   then echo "\${color9}"$1    # HOT
else echo "\${color8}"$1       # WARM

exit 0

I would like to also thank Cammy for fine tuning this script, I myself had been having the issue that Cammy describes below.


Ok, this might be useful to some people.
Now that I've added the colorize scripts to my conky, I'm getting a tempfile called "60".
I noticed that I get this if I ran the hdd colorize script as a program in terminal. I also get a error messages.
I compared the hdd script to the other two, and it ended up being the only one that still used < and > instead of -lt and -gt.
When I changed the < and > to -lt and -gt, I stopped getting the file and the error messages.
Just FYI in case anyone else has run into this.


As a side note I’d like to thank Crinos512 for this script, I’ve been using it since the day I found it and figured out how to put it in my conky:
${font DejaVu Sans Mono:bold:size=9}${color3}CPU: ${color5}${execpi 8 sensors | grep 'CPU Temp' | cut --characters 15-16 | xargs ~/Conky/scripts/<span style="color: #800000;"></span>}°${color}${goto 65}${color3}Core: ${execpi 8 sensors | grep 'Core0' | cut --characters 15-16 | xargs ~/Conky/scripts/<span style="color: #800000;"></span>}°${color}${goto 135}${color3}M/B: ${execpi 8 sensors | grep 'M/B Temp' | cut --characters 15-16 | xargs ~/Conky/scripts/<span style="color: #800000;"></span>}°${color}${goto 200}${color3}GPU: ${execpi 8 sh -c "DISPLAY=:0.0 nvidia-settings -q gpucoretemp | grep Attribute | cut --characters 41-42" | xargs ~/Conky/scripts/<span style="color: #800000;"></span>}°${font}
And as Crinos512 suggested then, make different scripts with names to show theirs usage, as each component in our computers have different default values. The only thing you need to change (other than the name) is the numbers in this part :
Don’t even need to change COOL – WARM for High – Low, Wide – Narrow whatever, in the script they are only “flags” anyway.
This script is probably one of the most used scripts I have seen since it’s creation and as such we all owe a Thank You to Crinos512.
Happy conkying. Bruce

Happy Conkying to you too Bruce, and to all of you!

– Crinos512

Personal tools