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

Reload Sound from command line/script #179

Open
py5 opened this issue May 11, 2018 · 8 comments
Open

Reload Sound from command line/script #179

py5 opened this issue May 11, 2018 · 8 comments

Comments

@py5
Copy link

py5 commented May 11, 2018

Hi, pnmixer is great, but it'd be even better if it were possible reload sound from scripts and terminal commands. Many Openbox/Tint2 users use scripts to control it's features, including audio. I, for example, use scripts to switch between headphones (HDMI) and speakers (internal audio), and have to kill and restart PNMixer every time I do that.

@hasufell
Copy link
Collaborator

hasufell commented May 12, 2018

I, for example, use scripts to switch between headphones (HDMI) and speakers (internal audio)

What does that even mean? Switch what?

@stratosjack
Copy link

stratosjack commented May 20, 2018

I'm using pactl set-card-profile to switch between two card profiles, pci-builtin and usb-headphones.
Every time I call this script, pnmixer's volume up/volume down functionality stops working for the new card.
This persists, waiting for 10 secs doesn't help. I need to press on "Reload Sound" to fix it.
Although behaves properly when I switch back to the old card.

@py5
Copy link
Author

py5 commented May 23, 2018

@hasufell , I mean this, via shell script or command line...

# Set output to HDMI (headphones)
pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo

# Set output to Analog (speakers)
pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo

When I switch between those two card profiles, pnmixer doesn't detects the change, and I need reload it manually, or via script with...

killall pnmixer && pnmixer

If there was an option to reload it, for example a "--reload" parameter, or if the change of the audio output was auto-detected, it would be great!

@stratosjack
Copy link

stratosjack commented May 23, 2018

^ Your code above seems more than enough for me!
This is a PulseAudio compatibility problem, you should probably tag it with "pulseaudio"...

@py5
Copy link
Author

py5 commented May 23, 2018

@stratosjack , the point is that I know that pulseudio support "needs to be implemented from scratch and will likely not happen", and the "Reload Sound" menu entry functionality is already implemented and works. That's why I'd just like to have this as an option from CL/script instead of clicking.

@hasufell
Copy link
Collaborator

If there was an option to reload it, for example a "--reload" parameter

I don't really know what that means. You want to spawn a second pnmixer instance? Otherwise you are asking for a non-trivial dbus interface.

That's why I'd just like to have this as an option from CL/script instead of clicking.

This is too vague to be implementable. How would it work?

@stratosjack
Copy link

stratosjack commented May 25, 2018

@hasufell
Forgive my ignorance, I'm not good at C++ or Kernel coding, but
my opinion is that audio_should_reload() on soundcard change.
But then again, this is a pa event, didn't say it is trivial.
I don't think its a feature here, rather more like a pa bug.

@hasufell
Copy link
Collaborator

hasufell commented May 26, 2018

Well, as stated above, there are only two possibilities:

  1. introduce real PulseAudio support (which will indeed require a complete rewrite. I've attempted that feature once and it simply doesn't work with the current architecture)
  2. make this a single-instance app with dbus support to send arbitrary commands to the running app (also non-trivial)

Maybe we could also hijack unix signaly, but they are asynchronous too and need some odd hacks to make work with gtk+ via pipes or something, see http://askra.de/software/gtk-signals/x2992.html if you want to give that a shot. Then you could do something like kill -SIGUSR1 <pnmixer-pid>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants