Conky Show Fahrenheit instead of Celcius
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Conky Show Fahrenheit instead of Celcius
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Conky Show Fahrenheit instead of Celcius
the interested line is:
strip the conky markup and in a terminal we can run directly:
But, that output isn't too useful alone to be able to make a conversion. We can't do math on it directly and of course it already has the C there.. and there's the other extra characters.
I get no output and if I just check sensors command I do see I could grep for line 'temp1', But also, the actual temp is in the second position so I end up with:
Anyway, but we do know that this output is very predictable. We should know the temp will never come out as a single digit going below 10 degrees(or 3 character ie. 9.5). So we can safely assume in this case that the output will always be 7 characters total. That's the + sign, then 4 characters making up the numeric temperature(54.2), then the degree sign and C. So, use cut. ( check on terminal: cut --help )
continue the processing with:
(sidenote: there is the possibility that the output could come out as 100 degrees C which adds another character, but in this case it's not so bad it would only change the math by cutting off the decimal place... well 100C is just really bad anyway so who cares whether conky works or not during a fire)
try it on terminal:
I think the math functions we want, and to be able to get good formatting, need to receive a variable, so we make the whole chunk into a variable. -talking about bc:
can echo to check:
Honestly I don't know how to do any of this stuff, but I just go searching the internet tubes and doing some tests and more searching and using <command> --help and/or man <command>.
now it's ready to convert:
..because bc wants a formulated string piped into it. That's what all the example I found said.
So, now, that should work for the most part. But it should really be dressed back up with at least a degree marker so it's obvious what it is specifying.
the new incomplete line looks like this:
Code: Select all
${color6}Cpu Temp ${alignr}${color6}${execi 10 sensors | grep 'Core 0' | awk {'print $3'}}${color}
Code: Select all
sensors | grep 'Core 0' | awk {'print $3'}
I get no output and if I just check sensors command I do see I could grep for line 'temp1', But also, the actual temp is in the second position so I end up with:
Code: Select all
sensors | grep 'temp1' | awk {'print $2'}
continue the processing with:
Code: Select all
cut -c2-5
try it on terminal:
Code: Select all
sensors | grep 'Core 0' | awk {'print $3'} | cut -c2-5
I think the math functions we want, and to be able to get good formatting, need to receive a variable, so we make the whole chunk into a variable. -talking about bc:
Code: Select all
CTMP=$(sensors | grep 'Core 0' | awk {'print $3'} | cut -c2-5)
Code: Select all
CTMP=$(sensors | grep 'Core 0' | awk {'print $3'} | cut -c2-5); echo $CTMP;
Honestly I don't know how to do any of this stuff, but I just go searching the internet tubes and doing some tests and more searching and using <command> --help and/or man <command>.
now it's ready to convert:
celcius_temp * 9 / 5 + 32
Code: Select all
CTMP=$(sensors | grep 'Core 0' | awk {'print $3'} | cut -c2-5); echo "scale=1; ${CTMP} * 9 / 5 + 32" | bc
So, now, that should work for the most part. But it should really be dressed back up with at least a degree marker so it's obvious what it is specifying.
the new incomplete line looks like this:
Code: Select all
${color6}Cpu Temp ${alignr}${color6}${execi 10 CTMP=$(sensors | grep 'Core 0' | awk {'print $3'} | cut -c2-5); echo "scale=1; ${CTMP} * 9 / 5 + 32" | bc}${color}
Re: Conky Show Fahrenheit instead of Celcius
I would use
It's just text, so you just observe the typical scheming there depending on which color or whatever. If you want a different color go to the end of the line and encapsulate it in some color markers. Or you could use the exising color and keep it inside the existing markers.
°F
for sure. It's just text, so you just observe the typical scheming there depending on which color or whatever. If you want a different color go to the end of the line and encapsulate it in some color markers. Or you could use the exising color and keep it inside the existing markers.
Re: Conky Show Fahrenheit instead of Celcius
Code: Select all
Up : $uptime
DNUP: ${color green}${downspeedf wlx74da383b4124} ${upspeedf wlx74da383b4124}KiB : ${color yellow}/SDA:${diskio sda} ${color}
CPU%: ${cpu cpu1}% ${cpu cpu2}% : CPUf: ${freq cpu1} ${freq cpu2}
CTMP: ${exec sensors -f | grep 'Core 0' | cut -c15-21 } ${exec sensors -f | grep 'Core 1' | cut -c15-21 }F
RAM : $mem/$memmax - $memperc% ${membar 6}
SWP : $swap/$swapmax - $swapperc% ${swapbar 6}
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Your data and OS are backed up....right?
Re: Conky Show Fahrenheit instead of Celcius
lol..Flemur wrote: ⤴Fri May 11, 2018 9:26 amCode: Select all
CTMP: ${exec sensors -f | grep 'Core 0' | cut -c15-21 } ${exec sensors -f | grep 'Core 1' | cut -c15-21 }F
sensors -f
. Who'da thunk it. And why not just cut the temp right out of it since it's always predictable output. good stuff.
Re: Conky Show Fahrenheit instead of Celcius
Code: Select all
${color Tan1}CPU Usage:${color9}$alignr${cpubar 8,145} ${color9}$cpu%@${freq_g cpu}GHz
${color1}CPU 0 ${offset 9}${color9}${cpu cpu0}% (${execi 8 sensors | grep -A 1 'temp1' | cut -c16-19 | sed '/^$/d'}°C)
${color1}CPU 1 ${offset 9}${color9}${cpu cpu1}% (${execi 8 sensors | grep -A 1 'temp1' | cut -c16-19 | sed '/^$/d'}°C)
Re: Conky Show Fahrenheit instead of Celcius
so in grepasinoro wrote: ⤴Fri May 11, 2018 10:22 amCode: Select all
${color1}CPU 0 ${offset 9}${color9}${cpu cpu0}% (${execi 8 sensors | grep -A 1 'temp1' | cut -c16-19 | sed '/^$/d'}°C)
-A 1
gives an extra line after it finds the 'temp1' line, then cut brings the right data from the correct line, but then sed removes the rest and the extra line? Is that correct?from grep:
is it the same thing:-A, --after-context=NUM print NUM lines of trailing context
Code: Select all
${color1}CPU 0 ${offset 9}${color9}${cpu cpu0}% (${execi 8 sensors | grep 'temp1' | cut -c16-19}°C)
Code: Select all
${color1}CPU 0 ${offset 9}${color9}${cpu cpu0}% (${execi 8 CTMP=$(sensors | grep 'temp1' | cut -c16-19); echo -n ${CTMP}"°C / "; echo "scale=1; ${CTMP} * 9 / 5 + 32" | bc}°F)
Re: Conky Show Fahrenheit instead of Celcius
Just curious here...why use ${exec sensors ... } instead of using ${hwmon} or ${platform} for cpu temp?
Re: Conky Show Fahrenheit instead of Celcius
I've always used hwmon, as that's how I first saw it, and exec seemed like something for advanced things.
I would think hwmon would be a more efficient approach, although the data is potentially different on each system so each person has to know what to go looking for(or just randomly test devices 0, 1, etc. and for each possible sensor 0, 1, 2), to tweak each config. Maybe it seems easier just looking at the sensors output then finding how to grep it for the situation?
but, for that matter, the output from sensors is equally different on any system too, and you still end up tweaking the values.
The conky variables doc does say,
"exec: Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch."
So, it's a good point, and in these cases it would also eliminate the grep, cut, and more, even aside from the more resources of using exec.
Re: Conky Show Fahrenheit instead of Celcius
Makes sense, thankfully I have yet to run into a situation where hwmon or platform didn't work for me. Using exec sensors for something as simple as CPU temp seems to add complexity to a simple task, but whatever works, works...(hopefully)zcot wrote: ⤴Wed May 16, 2018 4:00 pmI've always used hwmon, as that's how I first saw it, and exec seemed like something for advanced things.
I would think hwmon would be a more efficient approach, although the data is potentially different on each system so each person has to know what to go looking for(or just randomly test devices 0, 1, etc. and for each possible sensor 0, 1, 2), to tweak each config. Maybe it seems easier just looking at the sensors output then finding how to grep it for the situation?
but, for that matter, the output from sensors is equally different on any system too, and you still end up tweaking the values.
The conky variables doc does say,"exec: Executes a shell command and displays the output in conky. warning: this takes a lot more resources than other variables. I'd recommend coding wanted behaviour in C and posting a patch."
So, it's a good point, and in these cases it would also eliminate the grep, cut, and more, even aside from the more resources of using exec.