--- man/pactl.1.xml.in | 5 +++++ shell-completion/bash/pulseaudio | 3 ++- shell-completion/zsh/_pulseaudio | 1 + src/utils/pactl.c | 25 ++++++++++++++++++++++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/man/pactl.1.xml.in b/man/pactl.1.xml.in index 39569b6b..411c4d59 100644 --- a/man/pactl.1.xml.in +++ b/man/pactl.1.xml.in @@ -250,6 +250,11 @@ License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. <optdesc><p>Subscribe to events, pactl does not exit by itself, but keeps waiting for new events.</p></optdesc> </option> + <option> + <p><opt>subscribe-signals</opt></p> + <optdesc><p>Subscribe to signals. Like subscribe, but waits for signals instead of subscription events.</p></optdesc> + </option> + </section> <section name="Authors"> diff --git a/shell-completion/bash/pulseaudio b/shell-completion/bash/pulseaudio index e473b9c2..b815f223 100644 --- a/shell-completion/bash/pulseaudio +++ b/shell-completion/bash/pulseaudio @@ -120,7 +120,8 @@ _pactl() { set-source-port set-sink-volume set-source-volume set-sink-input-volume set-source-output-volume set-sink-mute set-source-mute set-sink-input-mute set-source-output-mute - set-sink-formats set-port-latency-offset subscribe help) + set-sink-formats set-port-latency-offset subscribe + subscribe-signals help) _init_completion -n = || return preprev=${words[$cword-2]} diff --git a/shell-completion/zsh/_pulseaudio b/shell-completion/zsh/_pulseaudio index 0e9e89bd..10510aa6 100644 --- a/shell-completion/zsh/_pulseaudio +++ b/shell-completion/zsh/_pulseaudio @@ -264,6 +264,7 @@ _pactl_completion() { 'set-source-output-mute: mute a recording stream' 'set-sink-formats: set supported formats of a sink' 'subscribe: subscribe to events' + 'subscribe-signals: subscribe to signals' ) _describe 'pactl commands' _pactl_commands diff --git a/src/utils/pactl.c b/src/utils/pactl.c index e9bf005b..ee355c3d 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -130,7 +130,8 @@ static enum { SET_SOURCE_OUTPUT_MUTE, SET_SINK_FORMATS, SET_PORT_LATENCY_OFFSET, - SUBSCRIBE + SUBSCRIBE, + SUBSCRIBE_SIGNALS } action = NONE; static void quit(int ret) { @@ -1184,6 +1185,17 @@ static void context_subscribe_callback(pa_context *c, pa_subscription_event_type fflush(stdout); } +static void context_signal_callback(pa_context *c, const char *sender, const char *signal, const char *signal_info, void *userdata) { + pa_assert(c); + + printf(_("Signal '%s' from %s\n"), + signal, + sender); + if (signal_info) + printf(_("Signal Info: '%s'\n"), signal_info); + fflush(stdout); +} + static void context_state_callback(pa_context *c, void *userdata) { pa_operation *o = NULL; @@ -1421,6 +1433,12 @@ static void context_state_callback(pa_context *c, void *userdata) { NULL); break; + case SUBSCRIBE_SIGNALS: + pa_context_set_signal_callback(c, context_signal_callback, NULL); + + o = pa_context_subscribe_signals(c, (uint64_t) -1, NULL, NULL); + break; + default: pa_assert_not_reached(); } @@ -1581,6 +1599,7 @@ static void help(const char *argv0) { printf("%s %s %s %s\n", argv0, _("[options]"), "set-sink-formats", _("#N FORMATS")); printf("%s %s %s %s\n", argv0, _("[options]"), "set-port-latency-offset", _("CARD-NAME|CARD-#N PORT OFFSET")); printf("%s %s %s\n", argv0, _("[options]"), "subscribe"); + printf("%s %s %s\n", argv0, _("[options]"), "subscribe-signals"); printf(_("\nThe special names @DEFAULT_SINK@, @DEFAULT_SOURCE@ and @DEFAULT_MONITOR@\n" "can be used to specify the default sink, source and monitor.\n")); @@ -2019,6 +2038,10 @@ int main(int argc, char *argv[]) { action = SUBSCRIBE; + else if (pa_streq(argv[optind], "subscribe-signals")) + + action = SUBSCRIBE_SIGNALS; + else if (pa_streq(argv[optind], "set-sink-formats")) { int32_t tmp; -- 2.11.0