From 829a1a48d9a4e20631f6c551d68cac62339be763 Mon Sep 17 00:00:00 2001 From: Mathis Felardos Date: Wed, 2 Feb 2022 19:24:36 +0100 Subject: [PATCH] Replace pacmd calls with pactl to support Pipewire `pacmd` does not work with Pipewire, use `pactl` where possible instead Co-authored-by: EgZvor --- i3pystatus/pulseaudio/__init__.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/i3pystatus/pulseaudio/__init__.py b/i3pystatus/pulseaudio/__init__.py index 76cac532..3b2b4062 100644 --- a/i3pystatus/pulseaudio/__init__.py +++ b/i3pystatus/pulseaudio/__init__.py @@ -198,12 +198,9 @@ def sink_info_cb(self, context, sink_info_p, eol, _): raise Exception("bar_type must be 'vertical' or 'horizontal'") selected = "" - dump = subprocess.check_output("pacmd dump".split(), universal_newlines=True) - for line in dump.split("\n"): - if line.startswith("set-default-sink"): - default_sink = line.split()[1] - if default_sink == self.current_sink: - selected = self.format_selected + default_sink = subprocess.check_output("pactl get-default-sink".split()).strip() + if default_sink == self.current_sink: + selected = self.format_selected self.output = { "color": color, @@ -229,16 +226,16 @@ def change_sink(self): next_sink = self.current_sink if self.move_sink_inputs: - sink_inputs = subprocess.check_output("pacmd list-sink-inputs".split(), + sink_inputs = subprocess.check_output("pactl list-sink-inputs".split(), universal_newlines=True) for input_index in re.findall(r'index:\s+(\d+)', sink_inputs): - command = "pacmd move-sink-input {} {}".format(input_index, next_sink) + command = "pactl move-sink-input {} {}".format(input_index, next_sink) # Not all applications can be moved and pulseaudio, and when - # this fail pacmd print error messaging + # this fail pactl print error messaging with open(os.devnull, 'w') as devnull: subprocess.call(command.split(), stdout=devnull) - subprocess.call("pacmd set-default-sink {}".format(next_sink).split()) + subprocess.call("pactl set-default-sink {}".format(next_sink).split()) def switch_mute(self): subprocess.call(['pactl', '--', 'set-sink-mute', self.current_sink, "toggle"])