Restart Conky when resuming from Suspend

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
newlyminted7
Level 5
Level 5
Posts: 558
Joined: Sat Jan 02, 2021 4:44 pm

Re: Restart Conky when resuming from Suspend

Post by newlyminted7 »

Well, I've done a bunch of testing over a few days, giving a few days for each change, and it does appear to be the call to my audacious shell script that is the culprit (or the script itself) that is causing the CPU usage to increase slowly over time ${execi 3 ~/.conky/aud_song.sh}. I still have no idea why, though.

I tried using conky's Audacious API and replaced the call to the shell script with ${audacious_title 65} and it looked like it fixed the problem, but I can't get it to wrap the song title, and truncating it to 65 characters isn't going to display enough information for everything I play with Audacious.

I'm not sure how to make text wrap in Conky. Or how to improve my shell script. Or what other ideas to try. Any suggestions?
newlyminted7
Level 5
Level 5
Posts: 558
Joined: Sat Jan 02, 2021 4:44 pm

Re: Restart Conky when resuming from Suspend

Post by newlyminted7 »

Sure enough right after I posted that I found a way to call audtool using exec and that allowed me to pipe it to fold to 30 characters, which wraps the song title okay:
${exec audtool --current-song | fold -sw 30}
So far this is working and I will keep an eye on the CPU usage over the next few days.
newlyminted7
Level 5
Level 5
Posts: 558
Joined: Sat Jan 02, 2021 4:44 pm

Re: Restart Conky when resuming from Suspend

Post by newlyminted7 »

Update: The Audacious code does appear to be the problem. Specifically, this:

Code: Select all

${if_match "${audacious_status}" == "Playing"}\
${voffset 3}${color orange}${font :size=8}♫ ${voffset 2}NOW PLAYING:${color} ${voffset -2}$stippled_hr
${font DejaVu Sans Mono:size=7}${exec audtool --current-song | fold -sw 30}${font}\
${endif}${voffset 5}
I kept an eye on it over the course of about 5 days and it got up to 30% CPU usage with every Conky tick (it should stay around 1-2%). The memory usage also increased from 0.1% to 0.3% (although negligable, it did increase, when it otherwise shouldn't increase at all from 0.1%).

All I can think of is that there must be something wrong with their Conky/Audacious API. This implementation is a change from my original code which called an external shell script which obtained the song info (included in an earlier post in this thread). I figured this implementation would be more efficient than the other since it doesn't call an external script, but this code still has the same CPU and memory usage problem.

I might look into restarting Conky upon every login, after all, since I do like having Conky display the currently playing Audacious song title. Unless you guys have any other ideas or suggestions?
User avatar
Termy
Level 12
Level 12
Posts: 4248
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Restart Conky when resuming from Suspend

Post by Termy »

newlyminted7 wrote: Mon Jul 19, 2021 2:53 pm Unless you guys have any other ideas or suggestions?
That sucks. Maybe the problem is fixed in a newer release? You could look into somehow getting a newer version of it and/or Audacious.
I'm also Terminalforlife on GitHub.
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: Restart Conky when resuming from Suspend

Post by zcot »

I found the same issue here. In fact, if you are not even running Audacious but use that conky script and never even open Audacious or start any songs it's the same result.

-found a mention of it on the conky github.

However, some conky code like this would solve the issue:

Code: Select all

${execi 3 playerctl status}
${execi 3 playerctl metadata artist}
${execi 3 playerctl metadata title}
-you would want to have installed the playerctl package.

I also see in Audacious, the plugin "Song Change". There's a variety of equal solutions I would think.
newlyminted7
Level 5
Level 5
Posts: 558
Joined: Sat Jan 02, 2021 4:44 pm

Re: Restart Conky when resuming from Suspend

Post by newlyminted7 »

Very interesting, zcot! Thank you for posting this.
Although, I didn't have much luck with it. The first time I tried it Conky wouldn't launch, the next time it showed what I had playing last in my web browser. I can't figure out how to tell it to only look at Audacious. Any idea on how to do that? I'm going to keep researching this, though.
Thanks again.

UPDATE: I figured it out, I used the -p flag and passed in "audacious", and it worked:

Code: Select all

${execi 3 playerctl -p audacious status}
${execi 3 playerctl -p audacious metadata artist}
${execi 3 playerctl -p audacious metadata title}
Very happy! Thank you very much, zcot.
I'll keep an eye on it for a few days, but hopefully this does the trick!
newlyminted7
Level 5
Level 5
Posts: 558
Joined: Sat Jan 02, 2021 4:44 pm

Re: Restart Conky when resuming from Suspend

Post by newlyminted7 »

Well, zcot, it looks like you did it - thank you very much!

I watched it over a few days and it hasn't increased in CPU usage in htop, which is great. Maybe there is a bug somewhere in the API between Conky and Audacious, who knows.

This has been a hassle for me for some time now and I am really happy it is fixed.

So thanks again and much appreciated!
User avatar
zcot
Level 9
Level 9
Posts: 2838
Joined: Wed Oct 19, 2016 6:08 pm

Re: Restart Conky when resuming from Suspend

Post by zcot »

Great news!

Yes, I'm not sure on where the problem lies. Is it in the current Audacious code or Conky? I would guess one or other of those packages could've changed enough to where the problem became present. I didn't really look into that though since it would involve changing one or the other. -maybe not a big deal,

-but the alternate solution is not bad in my opinion, and easy.

good to get that worked out! Glad you are happy about that!
Locked

Return to “Scripts & Bash”