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?
-
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– math4totsCommented 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
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
-
2The
execi
interval can't be lower than the update interval (see the man page). FWIW, no need to restartconky
, if you send itSIGUSR1
orSIGHUP
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. 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 thekillall
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. Commented Oct 10, 2013 at 17:04
-
1Looking at the source code, conky decides to update if
select
returns -1. You could ptrace it and hook around theselect
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 -
2Worth noting - reloading the init file does not re-execute
texeci
blocks with a long interval.– IiridaynCommented May 31, 2019 at 18:59