Using ${hwmon 0 temp 1 1.0 0.0} I can get conky to display the temperature, but it displays an integer value "41", while running cat /sys/class/hwmon/hwmon0/temp1_input returns 40750. So clearly more accuracy is available.
Changing the conky config to ${hwmon 0 temp 1 1000.0 0.0}, conky displays the full value, but I would like it to round to 1 or 2 decimal places (preferably to be able to specify how many digits I want).
As a side note - how does conky even "know" the raw value is given in milli-Celsius anyway?
As a side note - how does conky even "know" the raw value is given in milli-Celsius anyway?
Author reads documentations. https://www.kernel.org/doc/Documentation/hwmon/sysfs-interface
@lasers can you test my latest commit and verify it ?
conky.text = [[${hwmon 0 temp 1 1.0 0.0} // ${hwmon 0 temp 1 1000.0 0.0 0.0}]]
56 // 56000
How should I round it to 1 or 2 decimal places?
You can't round it lower than 2 decimal places, e.g: 56 can't become 5.
Going off on his word, but I think he really want precision. 40750 --> 40.7 or 40.75
EDIT: Also, there is a 1000 variable * factor + offset. I got lost trying to set up two things.
With the current code we can't print float
I'll poke around to create second wrapper around the "temp", instead using hwmon 0 temp 1 1.0 0.0 to become hwmon 0 temp2 1 1.0 0.0
Dont know will it work or not, have to try.
@brndnmtthws Will you accept by default to print the numbers in float instead pure integer ?
to become:
int temp_print(char *p, size_t p_max_size, double n,
enum TEMP_UNIT input_unit) {
float out;
size_t plen;
out = convert_temp_output(n, input_unit);
plen = spaced_print(p, p_max_size, "%.2f", 3, out);
return static_cast<int>(!(plen >= p_max_size));
}
@lasers Can you test my latest commit with the following in conky.conf:
${hwmon 0 temp2 1 1.0 0.0}
${hwmon 1 temp 1 1.0 1.0 1.0}
where temp2 should print the temperature in floating mode.
@su8 yeah I think having decimals for temp by default is fine.
Thank you for reporting, it has been fixed in https://github.com/brndnmtthws/conky/commit/a3b7905df65a1c5bafce65e42aac09fbef346bfe commit
Most helpful comment
@su8 yeah I think having decimals for temp by default is fine.