File tree 1 file changed +9
-17
lines changed
1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -283,26 +283,18 @@ function showOSD() {
283
283
284
284
285
285
function listen() {
286
- local firstRun=0
286
+ # If this is the first time start by printing the current state. Otherwise,
287
+ # directly wait for events. This is to prevent the module being empty until
288
+ # an event occurs.
289
+ output
287
290
288
291
# Listen for changes and immediately create new output for the bar.
289
292
# This is faster than having the script on an interval.
290
- pactl subscribe 2> /dev/null | {
291
- while true ; do
292
- {
293
- # If this is the first time just continue and print the current
294
- # state. Otherwise wait for events. This is to prevent the
295
- # module being empty until an event occurs.
296
- if [ $firstRun -eq 0 ]; then
297
- firstRun=1
298
- else
299
- read -r event || break
300
- # Avoid double events
301
- if ! echo " $event " | grep -e " on card" -e " on sink" -e " on server" ; then
302
- continue
303
- fi
304
- fi
305
- } & > /dev/null
293
+ pactl subscribe 2> /dev/null | grep --line-buffered -e " on card" -e " on sink" -e " on server" | {
294
+ while read -r; do
295
+ # Read all stdin to flush unwanted pending events, i.e. if there are
296
+ # 15 events at the same time (100ms window), output is called once.
297
+ read -r -d ' ' -t 0.1 -n 10000
306
298
output
307
299
done
308
300
}
You can’t perform that action at this time.
0 commit comments