You are not logged in.
Pages: 1
I am trying to change the color of my CPU temp text in conky to green, yellow or red based on the CPU temp. I am getting this in my conky:
Temperature: color green33
Here is my conky line:
${voffset 1}${goto 40}Temperature: ${font Droid Sans:style=Bold:size=8}${execpi 120 sensors | grep Core0 | paste -s | cut -c15-18 | xargs ~/.conky/colorize.sh}${hwmon 0 temp 1}°C${color}${font}${alignr}
Here is my bash script:
#!/bin/bash
# colorize.sh
COOL=65
WARM=80
if [[ $1 < $COOL ]];
then
echo "color green"
elif [[ $1 > $WARM ]];
then
echo "color red"
else
echo "color yellow"
fi
exit 0
Any help would be greatly appreciated.
Thanks
Offline
It doesn't work like that.
Either you have to echo rgb color codes or echo something like color1 .. color5 and in the conky script assign the variables their color codes.
For e.g. in .conkyrc --
color1 8AD749 # Green
color2 EECE01 # Yellow
color3 F80E27 # Red
and in the script:
if [[ $1 < $COOL ]];
then
echo -n '${color1}'
elif [[ $1 > $WARM ]];
then
echo -n '${color3}'
else
echo -n '${color2}"
f
Last edited by debdj (2012-08-26 05:46:54)
Offline
why not include the whole sensors line in bash, rather than messing up conky that way:
temp=`sensors | grep core0 | cut -c15-18`
if [[ $temp < $COOL ]];
then
echo -n '${color1}$temp'
elif [[ $temp > $WARM ]];
then
echo -n '${color3}$temp'
else
echo -n '${color2}$temp"
fi
and then in conky:
${voffset 1}${goto 40}Temperature: ${font Droid Sans:style=Bold:size=8}${execpi 120 sh ~/.conky/colorize.sh}°C${color}${font}${alignr}
Ryzen 5900X 12 core/24 thread - RTX 3090 FE 24 Gb, Asus B550-F Gaming MB, 128Gb Corsair DDR4, Cooler Master N300 chassis, 5 HD (2 NvME PCI, 4SSD) + 1 x optical.
Linux user #545703
/ is the root of all problems.
Offline
temp=`sensors | grep core0 | cut -c15-18`
I'm a little OCD about these pipes... Awk seems so much tidier.
awk '/Core 0/ {print +$3}' <(sensors)
Offline
I'm a little OCD about these pipes...
That's what Mario said!
ᶘ ᵒᴥᵒᶅ
Offline
Using exec(p)(i) makes your conky run heavier, so, why wouldn't you use the built-in conky variables to achieve the same...
I'm using: (before "TEXT")
template2 ${color2}${if_match ${hwmon \1 temp \2}>75}${color orange}${if_match ${hwmon \1 temp \2}>90}${color red}${endif}${endif}${hwmon \1 temp \2}${color1}
and i call them like: (after "TEXT")
Temp ${template2 0 1}/${template2 1 1}/${template2 2 2}/${template2 2 4}
Of course you need to find out what numbers you need to pass to hwmon...
Offline
Thanks everyone. This is my first attemp at bash.
Offline
@flagators just for reference this is a great book for starters:: http://linuxcommand.org/tlcl.php
and this place got me started in shell scripting:: http://www.ibm.com/developerworks/views … +UNIX+Part
Offline
@debdj Thanks!
Offline
Pages: 1