Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pacmd calls with pactl to support Pipewire [final version] #836

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

hasB4K
Copy link
Contributor

@hasB4K hasB4K commented Feb 4, 2022

Hello,

I continued the work from @EgZvor (thank you!) in #818 and patched the remaining issue with default-sink in pactl.
I used this version for the last two weeks so far. I think this PR is directly megeable @enkore 😉

Fixes: #810

Best regards,
hasB4K

@hasB4K
Copy link
Contributor Author

hasB4K commented Apr 12, 2022

@terminalmage do you have the rights to merge this PR? :)

hasB4K added a commit to hasB4K/i3pystatus that referenced this pull request Nov 28, 2023
Comment on lines -237 to -240
# Not all applications can be moved and pulseaudio, and when
# this fail pacmd print error messaging
with open(os.devnull, 'w') as devnull:
subprocess.call(command.split(), stdout=devnull)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the code came from #552. Since this PR uses the method _call_pactl instead that internally uses subprocess.check_output, the messages on stdout that could come from pactl will always be discarded.

Comment on lines 234 to 243
def _call_pactl(self, pactl_arguments):
try:
output = subprocess.check_output(
["pactl"] + [str(arg) for arg in pactl_arguments],
universal_newlines=True)
return output
except Exception as exc:
self.logger.exception("Error while executing pactl")
self.output = {"color": self.color_error, "full_text": "Error while executing pactl"}
self.send_output()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every call of the functions subprocess.check_output or subprocess.call of this module were replaced in this PR by self._call_pactl.
This method call the pactl command with its arguments using subprocess.check_output() internally. The outputs are either treated by the callee or simply ignored.

If an error occurs, we update self.output with a minimal message and we notify the change using self.send_output(). The full stacktrace is available in the file logs (I checked) since self.logger.exception is now used.

@hasB4K
Copy link
Contributor Author

hasB4K commented Nov 28, 2023

@terminalmage let me know if the changes that I made are corresponding to what you had in mind 🙂

FYI, when pactl is not present, this is what is now displayed in i3bar:
Screenshot of the error

Copy link
Collaborator

@terminalmage terminalmage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one remaining small nitpick.

i3pystatus/pulseaudio/__init__.py Outdated Show resolved Hide resolved
@hasB4K
Copy link
Contributor Author

hasB4K commented Dec 1, 2023

@terminalmage Thanks for the review! Let me know if I need to fix something else 🙂

@terminalmage terminalmage merged commit 5348220 into enkore:current Dec 1, 2023
@terminalmage
Copy link
Collaborator

Thanks! Merged it just now.

@hasB4K hasB4K deleted the pipewire branch December 1, 2023 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for pipewire
2 participants