[modules/pulseaudio] fix pactl subscribe thread
calling "draw" too early causes status line to be messed up. see #917
This commit is contained in:
parent
ae04cc9897
commit
8d2cdebbaf
1 changed files with 9 additions and 18 deletions
|
@ -113,36 +113,27 @@ class Module(core.module.Module):
|
||||||
|
|
||||||
def __subscribe(self):
|
def __subscribe(self):
|
||||||
self.update2()
|
self.update2()
|
||||||
core.event.trigger("update", [self.id], redraw_only=True)
|
core.event.trigger("update", [self.id], redraw_only=False)
|
||||||
core.event.trigger("draw")
|
|
||||||
try:
|
try:
|
||||||
proc = subprocess.Popen("pactl subscribe",
|
proc = subprocess.Popen("pactl subscribe",
|
||||||
stdout = subprocess.PIPE,
|
stdout = subprocess.PIPE,
|
||||||
stderr = subprocess.PIPE,
|
stderr = subprocess.STDOUT,
|
||||||
shell = True
|
shell = True
|
||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
os.set_blocking(proc.stdout.fileno(), False)
|
|
||||||
while threading.main_thread().is_alive():
|
while threading.main_thread().is_alive():
|
||||||
r, w, e = select.select([proc.stdout], [], [], 1)
|
r, w, e = select.select([proc.stdout], [], [], 1)
|
||||||
|
|
||||||
if not (r or w or e):
|
if not (r or w or e):
|
||||||
continue # timeout
|
continue # timeout
|
||||||
|
# whateve we got, use it
|
||||||
line = 'test'
|
|
||||||
update = False
|
|
||||||
while line:
|
|
||||||
line = proc.stdout.readline().decode("ascii", errors="ignore")
|
|
||||||
if "client" in line:
|
|
||||||
update = True
|
|
||||||
|
|
||||||
if update:
|
|
||||||
self.update2()
|
self.update2()
|
||||||
core.event.trigger("update", [self.id], redraw_only=True)
|
core.event.trigger("update", [self.id], redraw_only=True)
|
||||||
core.event.trigger("draw")
|
core.event.trigger("draw")
|
||||||
while proc.stdout.readline().decode("ascii", errors="ignore"):
|
os.set_blocking(proc.stdout.fileno(), False)
|
||||||
pass
|
proc.stdout.read()
|
||||||
|
os.set_blocking(proc.stdout.fileno(), True)
|
||||||
|
|
||||||
def set_volume(self, amount):
|
def set_volume(self, amount):
|
||||||
util.cli.execute(
|
util.cli.execute(
|
||||||
|
|
Loading…
Reference in a new issue