falconindy / ponymix

CLI volume control for PulseAudio
MIT License
177 stars 27 forks source link

Add a command to test if the headphones are plugged in #23

Closed nogweii closed 10 years ago

nogweii commented 10 years ago

Similar to the is-muted command, a command to return 0/1 depending if there are headphones plugged into the computer.

A cursory look through the PulseAudio API docs didn't show any obvious leads. Hopefully you would have a better idea where to look.

falconindy commented 10 years ago

From one cat to another, this isn't really feasible. What's the greater purpose of this?

vodik commented 10 years ago

It technically is possible, the pa_sink_port_info struct is supposed to contain this information with the available field:

http://freedesktop.org/software/pulseaudio/doxygen/def_8h.html#a72f790c31bf10c1d244aa078c4cdb345

This port does not support jack detection / This port is not available, likely because the jack is not plugged in. / This port is available, likely because the jack is plugged in.

    const pa_sink_info* info = ...;
    if (info->active_port->available == PA_PORT_AVAILABLE_YES)
        ...

Is probably enough

nogweii commented 10 years ago

From one cat to another, this isn't really feasible. What's the greater purpose of this?

I use ponymix in various shell scripting scenarios. I would like some smarter scripts (like capping the volume, for instance) when I have headphones plugged in. That's the immediate use-case. Also a generic desire to be able to query the system for more information.