From 8d2cdebbafdb01f7ffc912555413fbc8bb9ee6e0 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Wed, 31 Aug 2022 19:05:08 +0200 Subject: [PATCH] [modules/pulseaudio] fix pactl subscribe thread calling "draw" too early causes status line to be messed up. see #917 --- bumblebee_status/modules/core/pulseaudio.py | 27 +++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/bumblebee_status/modules/core/pulseaudio.py b/bumblebee_status/modules/core/pulseaudio.py index 22d5b07..795751e 100644 --- a/bumblebee_status/modules/core/pulseaudio.py +++ b/bumblebee_status/modules/core/pulseaudio.py @@ -113,36 +113,27 @@ class Module(core.module.Module): def __subscribe(self): self.update2() - core.event.trigger("update", [self.id], redraw_only=True) - core.event.trigger("draw") + core.event.trigger("update", [self.id], redraw_only=False) try: proc = subprocess.Popen("pactl subscribe", stdout = subprocess.PIPE, - stderr = subprocess.PIPE, + stderr = subprocess.STDOUT, shell = True ) except: return - os.set_blocking(proc.stdout.fileno(), False) while threading.main_thread().is_alive(): r, w, e = select.select([proc.stdout], [], [], 1) if not (r or w or e): continue # timeout - - line = 'test' - update = False - while line: - line = proc.stdout.readline().decode("ascii", errors="ignore") - if "client" in line: - update = True - - if update: - self.update2() - core.event.trigger("update", [self.id], redraw_only=True) - core.event.trigger("draw") - while proc.stdout.readline().decode("ascii", errors="ignore"): - pass + # whateve we got, use it + self.update2() + core.event.trigger("update", [self.id], redraw_only=True) + core.event.trigger("draw") + os.set_blocking(proc.stdout.fileno(), False) + proc.stdout.read() + os.set_blocking(proc.stdout.fileno(), True) def set_volume(self, amount): util.cli.execute(