Skip to content

Commit

Permalink
Replace pacmd calls with pactl to support Pipewire
Browse files Browse the repository at this point in the history
`pacmd` does not work with Pipewire, use `pactl` where possible instead

Co-authored-by: EgZvor <[email protected]>
  • Loading branch information
hasB4K and EgZvor committed Feb 2, 2022
1 parent c4876ed commit 829a1a4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions i3pystatus/pulseaudio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"])
Expand Down

0 comments on commit 829a1a4

Please sign in to comment.