我让 Conky 用${exec bash /path/to/script/getvolume.sh}
. 但是我注意到在更改音量后,我必须等待一段时间才能让 Conky 更新。我是否可以编写另一个脚本changevolume.sh
,这样./changevolume.sh 12
不仅会改变音量,而且会在之后立即使 Conky 自行更新,这样我就不必等待通常的更新间隔期?
据我所知,除了conky
杀死并重新启动它之外,没有办法从外部强制更新。好消息是您不需要,您可以conky
使用以下update_interval
设置更频繁地更新:
update_interval 1
Run Code Online (Sandbox Code Playgroud)
这是一个配置选项,因此必须将其放置在您的 的标题中.conkyrc
,在TEXT
块之前。
请记住,时间间隔越小,conky
CPU 使用率越高,因为它将更频繁地运行。是否值得由您来决定。
唯一的其他选择是让您的getvolume.sh
脚本终止并重新启动conky
。将此行添加到脚本的末尾:
killall conky; conky &
Run Code Online (Sandbox Code Playgroud)
@Joseph R 在conky
的手册页中找到了这个:
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.
Run Code Online (Sandbox Code Playgroud)
因此,您可以conky
通过将此命令添加到您的末尾来强制重新读取其 init 文件getvolume.sh
:
killall -SIGUSR1 conky
Run Code Online (Sandbox Code Playgroud)