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?

math4tots
  • 2,685

1 Answers1

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
terdon
  • 242,166
  • 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. Oct 10 '13 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 Oct 10 '13 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. Oct 10 '13 at 17:04
  • @JosephR. agreed but I'm pretty sure it's the best he'll get :). – terdon Oct 10 '13 at 17:05
  • I'm more inclined to think that your first solution (lowering the update interval) is much better if the higher CPU usage is tolerable. – Joseph R. Oct 10 '13 at 17:11
  • @JosephR. the best would be execi, that way only one command needs to be run every second, not everything in the conkyrc. Mind you, my own conky updates every second and I have no issues with it. – terdon Oct 10 '13 at 17:15
  • 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. – Gilles 'SO- stop being evil' Oct 11 '13 at 00:51
  • 2
    Worth noting - reloading the init file does not re-execute texeci blocks with a long interval. – Iiridayn May 31 '19 at 18:59