From c2458e1857f70cc10dd84102ec7f74a239f8c059 Mon Sep 17 00:00:00 2001 From: Mehdi ABAAKOUK Date: Wed, 10 Jul 2019 07:48:01 +0200 Subject: [PATCH] pulseaudio: remove output when sink is gone (#750) When `sink` is set and you have USB card or Bluetooth headset. When the sink is created, the output is set and the module appear. But when the sink is deleted, the output is not deleted, and the module stay. This change detects when the sink is deleted and delete the output. --- i3pystatus/pulseaudio/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/i3pystatus/pulseaudio/__init__.py b/i3pystatus/pulseaudio/__init__.py index 0c070b8..f09f8e2 100644 --- a/i3pystatus/pulseaudio/__init__.py +++ b/i3pystatus/pulseaudio/__init__.py @@ -147,7 +147,7 @@ class PulseAudio(Module, ColorRangeModule): self.request_update(context) - def sink_info_cb(self, context, sink_info_p, _, __): + def sink_info_cb(self, context, sink_info_p, eol, _): """Updates self.output""" if sink_info_p: sink_info = sink_info_p.contents @@ -198,6 +198,9 @@ class PulseAudio(Module, ColorRangeModule): } self.send_output() + elif eol < 0: + self.output = None + self.send_output() def change_sink(self): sinks = list(s.split()[1] for s in self.sinks)