brndnmtthws / conky

Light-weight system monitor for X, Wayland (sort of), and other things, too
https://conky.cc
GNU General Public License v3.0
7.17k stars 615 forks source link

generic .conkyrc broken in version 1.10 #423

Closed booboo-at-gluga-de closed 6 years ago

booboo-at-gluga-de commented 6 years ago

In Conky 1.9 I could create a .conkyrc which fitted for multiple computers. E. g. a configuration working as well on computers with 2 and 4 CPU cores. I realized this with: ${color}CPU1 ${freq_g 1}Ghz ${cpu cpu1}%${alignc}${color red}${cpubar cpu1} ${if_empty ${cpu cpu2}}\ ${else}\ ${color}CPU2 ${freq_g 2}Ghz ${cpu cpu2}%${alignc}${color red}${cpubar cpu2} ${endif}\ ${if_empty ${cpu cpu3}}\ ${else}\ ${color}CPU3 ${freq_g 3}Ghz ${cpu cpu3}%${alignc}${color red}${cpubar cpu3} ${endif}\ ${if_empty ${cpu cpu4}}\ ${else}\ ${color}CPU4 ${freq_g 4}Ghz ${cpu cpu4}%${alignc}${color red}${cpubar cpu4} ${endif}\

With version 1.10 on computers with 2 CPUs this leads to the error: conky: obj->data.i 3 info.cpu_count 2 conky: attempting to use more CPUs than you have! Conky does not even start.

Even if I do not use the cpu object in the if clause, the problem stays: ${if_existing /proc/sys/kernel/sched_domain/cpu2}}\ ${else}\ ${color}CPU3 ${freq_g 3}Ghz ${cpu cpu3}%${alignc}${color red}${cpubar cpu3} ${endif}\ Leads to the same error.

The problem seems to be, that variables are evaluated even if found inside a not matching if statement. Please fix and re-enable generic .conkyrc files.

reprise5 commented 6 years ago

Something to note in case you were unaware: The rc syntax changed for conky 1.10 so this may be the problem too. There is a script here that you can try to convert your old 1.9 rc's, as well as some notes containing some information about the change.

Let me know if this wasn't helpful. If it was helpful and solved the problem, please close this issue.

legendre6891 commented 6 years ago

The step above doesn't solve the issue; in general, I think a better solution is to expose a variable holding the # of cores, i.e. info.cpu_count.

mswanson-me commented 6 years ago

This issue does not appear to be valid. On Conky 1.10.1, the multi-core configuration lines @booboo-at-gluga-de provided result in 4 red CPU meters on my computer. Please update this issue if needed, otherwise it will be closed in a few days.

booboo-at-gluga-de commented 6 years ago

On computers with 4 CPUs the configuration works as I wrote in the issue. The problem occurs on computers with less than 4 CPUs.

If you want to reproduce the error on an arbitrary machine, you might want to add more CPU sections than the computer has. On a 4 CPU machine you could add something like

${if_empty ${cpu cpu5}}\ ${else}\ ${color}CPU5 ${freq_g 5}Ghz ${cpu cpu5}%${alignc}${color red}${cpubar cpu5} ${endif}\

mswanson-me commented 6 years ago

Ah, I see. So I think this will depend on that ${cpu cpu5} varible. The man page shows:

cpu (cpuN) CPU usage in percents. For SMP machines, the CPU number can be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu cpuX} (X >= 1) are individual CPUs.

So this variable appears to be an attribute of the CPU core itself. If there is no CPU core 5, then there are no attributes for CPU core 5. Thus, is_empty would fail because the attribute it is checking doesn't exist.

Or I could be way off. :D I'll try to track this down within the code to confirm or deny my theory.

Thanks for updating the issue!

booboo-at-gluga-de commented 6 years ago

Sounds good, thank you! Waiting curiously for your findings...

mswanson-me commented 6 years ago

Hi again, I have confirmed my suspicion. Starting at line 391 of /src/common.cc, the cpu usage is defined as an attribute of each cpu core. If there's no core, there's no attribute, and you get the error. I'm going to go ahead and close this since this error is to be expected based on the core functionality of Conky.

Thanks for the patience and thanks for reporting this!

legendre6891 commented 6 years ago

I understand that this is 'expected behavior', but is there a plan to bring back the functionality so that a config may be written that displays the usage of every CPU core without advance knowledge of how many CPU cores there are (i.e., so that it works across machines).

If needed, I can open another bug report/feature request for this.

Thanks!

mswanson-me commented 6 years ago

For that, I'm going to have to defer to someone who has a deeper knowledge of the code base. I'll see if I can ping someone about this today.

mswanson-me commented 6 years ago

@brndnmtthws : Is the feature suggested here by @legendre6891 feasible? If so, I will re-open this issue.