6

I have Conky display my current volume with ${exec bash /path/to/script/getvolume.sh}. However I have noticed that after changing the volume, I have to wait a while for Conky to update. Is it possible for me to write another script changevolume.sh, so that ./changevolume.sh 12 would not only change the volume but also make Conky update itself immediately afterwards so that I don't have to wait for the usual update interval period?

4
  • possible duplicate of How to use command line to change volume?
    – Joseph R.
    Commented Oct 10, 2013 at 0:51
  • Not an exact duplicate, I know. But it's what your question boils down to.
    – Joseph R.
    Commented Oct 10, 2013 at 0:52
  • 1
    @JosephR. It is related but i'm not sure that's what it boils down to. Changing the volume is easy, but after changing it, I have to wait a few seconds for the results to be updated on Conky. What I want is a way for Conky to display the correct volume immediately after the volume has changed
    – math4tots
    Commented Oct 10, 2013 at 0:54
  • You're right. My bad. I wasn't paying attention. Close vote retracted.
    – Joseph R.
    Commented Oct 10, 2013 at 0:55

1 Answer 1

6

As far as I know, there is no way of externally forcing conky to update short of killing and restarting it. The good news is that you don't need to, you can just set conky to update more often using the update_interval setting:

update_interval 1

This is a configuration option, so it has to be placed in the header of your .conkyrc, before the TEXT block.

Bear in mind that the lower the interval, the higher conky's CPU usage since it will be running more often. It is up to you to decide if it is worth it.

The only other option would be to have your getvolume.sh script kill and restart conky. Add this line to the end of your script:

killall conky; conky &

@Joseph R found this in conky's man page:

   An easy way to force Conky to reload your ~/.conkyrc: "killall -SIGUSR1
   conky". Saves you the trouble of having to kill and then  restart.  You
   can now also do the same with SIGHUP.

So you could force conky to reread its init file by adding this command to the end of your getvolume.sh:

killall -SIGUSR1 conky
9
  • 2
    The execi interval can't be lower than the update interval (see the man page). FWIW, no need to restart conky, if you send it SIGUSR1 or SIGHUP it will reload its rc file (again see man page). I had posted this as an answer but deleted it because its effect will be disconcerting to the OP and is definitely not what he/she is looking for.
    – Joseph R.
    Commented Oct 10, 2013 at 16:56
  • @JosephR. I never suggested the execi interval be shorter than the update one. They are just two different ways of getting the desired behavior. And yes, I saw your answer (it's still visible to >10k users) but thought it was actually killing and restarting, just checked and saw that it doesn't. Should I add this to mine, or will you undelete your answer? Conky almost certainly forks for exec calls but the killall call causes it to rerun them so your answer seems fine to me.
    – terdon
    Commented Oct 10, 2013 at 17:02
  • Feel free to add my answer's content to yours. I still don't believe it's what the OP is looking for.
    – Joseph R.
    Commented Oct 10, 2013 at 17:04
  • 1
    Looking at the source code, conky decides to update if select returns -1. You could ptrace it and hook around the select syscall to return -1 when desired… It would be as much work as adding the feature to update upon receipt of a signal. Commented Oct 11, 2013 at 0:51
  • 2
    Worth noting - reloading the init file does not re-execute texeci blocks with a long interval.
    – Iiridayn
    Commented May 31, 2019 at 18:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .