Conky GPU clock display weirdness

Hello everyone!

I am trying to update my conky config (cobbled together from other people’s fantastic work) and running into some strange display issue that I am not educated enough to solve.

Screenshot-2022-11-04_16-12

When the GPU clock is >0 everything displays correctly.
However, once the card clocks down to zero, there is an unsightly linebreak happening.

Screenshot-2022-11-04_16-13

My GPU config looks like this:

${color5}${font SF Pro Text:size=10}G P U   ${hr 2}${font}${color}
${color2}${voffset 2}Radeon 6900 XT:${color}${alignr} @ ${color3}${exec grep -Po '\d+:\s\K(\d+)(?=.*\*$)' /sys/class/drm/card0/device/pp_dpm_sclk} MHz$color${font}
${color2}Mem:${color}${alignr}     ${exec numfmt --to=iec < /sys/class/drm/card0/device/mem_info_vram_used}
${color2}Usage: ${color}${exec cat /sys/class/drm/card0/device/gpu_busy_percent}%${color}${alignr}${color2}Driver: ${color3}Mesa ${execi 60 glxinfo | grep Version | cut -c 14-23}${color}
${color2}Temp Edge: ${color3}${execi 5 sensors | grep edge | cut -c 16-23}${alignr -13}${color2}Temp Junction: ${color3}${execi 5 sensors | grep junction | cut -c 16-23}${color}
${color black}${alignr}${offset -25}${execgraph "cat /sys/class/drm/card0/device/gpu_busy_percent" 24,320 000000 AAAAAA}

Would any of you kind people know how to solve this issue?

Thank you,
Beer

Hi @Beerfoo,

My guess is that when the clock speed reaches 0, the file /sys/class/drm/card0/device/pp_dpm_sclk is gone, or deleted, or something, making the grep in this line:

…not return anything.

I’m guessing you could, perhaps should, build an if statement to check if the file exists, and if it does, print the clock speed and if it doesn’t, print 0Mhz. Or some such.

Edit:

Have a look here:

https://stackoverflow.com/questions/57468443/how-to-use-if-existing-statment-with-path-string

Hey @Mirdarthos,

thank you for your reply!
I had a look at that file and the contents are;

cat /sys/class/drm/card0/device/pp_dpm_sclk           
0: 0Mhz *
1: 0Mhz *

versus

cat /sys/class/drm/card0/device/pp_dpm_sclk
0: 500Mhz *
1: 2660Mhz 

It would appear that in the case of the card being both lines are being picked up by the regex which is consistent with the output I am seeing.

Seems the solution would be to just limit it to either only looking at the “0:” value or contrain it to only pick up the first line.

After changing the statement to…

${color2}${voffset 2}Radeon 6900 XT:${color}${alignr} @ ${color3}${exec head -1 /sys/class/drm/card0/device/pp_dpm_sclk | grep -Po '\d+:\s\K(\d+)(?=.*\*$)' } MHz $color${font}

I no longer get the double output, which was great!

However firing up a game quickly revealed the flaw of the solution because we no longer get any output in conky past 500 Mhz, since regex is looking for “*” in line 1.
Sadly this is no longer true when running a game since the file contents are now:

cat /sys/class/drm/card0/device/pp_dpm_sclk
0: 500Mhz 
1: 2570Mhz *
2: 2660Mhz 

Alas, limiting it to line 1 was no good.
Back to doing more research… :upside_down_face:

Solution for conky outputting double zero Mhz GPU values:

After a dipping my toes into the arcane wizardry that is Regex with utter bewilderment, I instead managed to solve it by using the -m 1 switch for grep.

working code:

${color2}${voffset 2}Radeon 6900 XT:${color}${alignr} @ ${color3}${exec grep -Pom 1 '\d+:\s\K(\d+)(?=.*\*$)' /sys/class/drm/card0/device/pp_dpm_sclk} MHz $color${font}

Screenshot-2022-11-04_19-57

@Mirdarthos Thank you for setting me on the right path!

:smiley: :beers:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.