You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It won't work with other audio servers like JACK, though.
228
+
229
+
### This script uses too much CPU
230
+
231
+
We use the `pactl subscribe` command to get notified of new events that may
232
+
occur in order to refresh the output. However, the command often outputs *a lot*
233
+
of events for a simple action, like increasing the volume. Instead of refreshing
234
+
for every single line it prints, we:
235
+
236
+
1. Wait for one event
237
+
2. Update the output first
238
+
3. Continue to listen for events until a timeout ends, or until we reach a large
239
+
enough number of them
240
+
4. Update the output again
241
+
5. Go back to step 1
242
+
243
+
This way, the first event will update quickly, and the following ones, which are
244
+
most likely unnecessary, will be ignored until some time passes. This reduces
245
+
the CPU usage, but it's not really perfect, as everyone percieves latency
246
+
differently, and it depends on the use-case.
247
+
248
+
The timer can be configured with `--listen-timeout-secs`, which has a default
249
+
value of `0.05` (50 ms). If you want less CPU usage, i.e., ignore more duplicate
250
+
events, you can bump it to, for example, `0.1` (100 ms). Or for faster refreshes
251
+
when performing multiple actions quickly, e.g., updating the volume with your
252
+
mousewheel, you can even use a smaller value.
253
+
254
+
### This script feels laggy when performing multiple actions quickly
255
+
256
+
Please refer to the previous question, as you can fix this by setting a smaller
257
+
refresh delay with `--listen-timeout-secs`.
258
+
210
259
## Sources
211
260
212
261
Part of the script and of this README's info was taken from [customlinux.blogspot.com](http://customlinux.blogspot.com/2013/02/pavolumesh-control-active-sink-volume.html), the creator. It was later adapted to fit polybar. It is also mixed with [the ArcoLinux version](https://github.com/arcolinux/arcolinux-polybar/blob/master/etc/skel/.config/polybar/scripts/pavolume.sh), which implemented the `listen` action to use less resources.
0 commit comments