]> code.delx.au - pulseaudio/commitdiff
pactl: Add a command for setting the default sink/source.
authorpoljar (Damir Jelić) <poljarinho@gmail.com>
Wed, 30 Jan 2013 17:51:57 +0000 (18:51 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Fri, 1 Feb 2013 05:16:20 +0000 (07:16 +0200)
This adds two new commands to pactl:
    set-default-sink
    set-default-source

This command has been part of the native protocol for a long time,
no reason not to expose it in pactl.

man/pactl.1.xml.in
src/utils/pactl.c

index 1dc063d32470995292d3b6a4ec59d0614bba63e6..29071b3f2565e587e2b858878bbec718a74152a2 100644 (file)
@@ -162,11 +162,21 @@ USA.
       <optdesc><p>Set the specified card (identified by its symbolic name or numerical index) to the specified profile (identified by its symbolic name).</p></optdesc>
     </option>
 
+    <option>
+      <p><opt>set-default-sink</opt> <arg>SINK</arg></p>
+      <optdesc><p>Make the specified sink (identified by its symbolic name) the default sink.</p></optdesc>
+    </option>
+
     <option>
       <p><opt>set-sink-port</opt> <arg>SINK</arg> <arg>PORT</arg></p>
       <optdesc><p>Set the specified sink (identified by its symbolic name or numerical index) to the specified port (identified by its symbolic name).</p></optdesc>
     </option>
 
+    <option>
+      <p><opt>set-default-source</opt> <arg>SOURCE</arg></p>
+      <optdesc><p>Make the specified source (identified by its symbolic name) the default source.</p></optdesc>
+    </option>
+
     <option>
       <p><opt>set-source-port</opt> <arg>SOURCE</arg> <arg>PORT</arg></p>
       <optdesc><p>Set the specified source (identified by its symbolic name or numerical index) to the specified port (identified by its symbolic name).</p></optdesc>
index 79b1545cb398d1d501361d8edacfbd660fcf83b6..020085dd762c8091c2e82c3a0f181b4069829171 100644 (file)
@@ -114,7 +114,9 @@ static enum {
     SUSPEND_SOURCE,
     SET_CARD_PROFILE,
     SET_SINK_PORT,
+    SET_DEFAULT_SINK,
     SET_SOURCE_PORT,
+    SET_DEFAULT_SOURCE,
     SET_SINK_VOLUME,
     SET_SOURCE_VOLUME,
     SET_SINK_INPUT_VOLUME,
@@ -1284,10 +1286,18 @@ static void context_state_callback(pa_context *c, void *userdata) {
                     pa_operation_unref(pa_context_set_sink_port_by_name(c, sink_name, port_name, simple_callback, NULL));
                     break;
 
+                case SET_DEFAULT_SINK:
+                    pa_operation_unref(pa_context_set_default_sink(c, sink_name, simple_callback, NULL));
+                    break;
+
                 case SET_SOURCE_PORT:
                     pa_operation_unref(pa_context_set_source_port_by_name(c, source_name, port_name, simple_callback, NULL));
                     break;
 
+                case SET_DEFAULT_SOURCE:
+                    pa_operation_unref(pa_context_set_default_source(c, source_name, simple_callback, NULL));
+                    break;
+
                 case SET_SINK_MUTE:
                     if (mute == TOGGLE_MUTE)
                         pa_operation_unref(pa_context_get_sink_info_by_name(c, sink_name, sink_toggle_mute_callback, NULL));
@@ -1491,6 +1501,7 @@ static void help(const char *argv0) {
     printf("%s %s %s %s\n", argv0, _("[options]"), "move-(sink-input|source-output)", _("#N SINK|SOURCE"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "suspend-(sink|source)", _("NAME|#N 1|0"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-card-profile ", _("CARD PROFILE"));
+    printf("%s %s %s %s\n", argv0, _("[options]"), "set-default-(sink|source)", _("NAME"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-port", _("NAME|#N PORT"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink|source)-volume", _("NAME|#N VOLUME"));
     printf("%s %s %s %s\n", argv0, _("[options]"), "set-(sink-input|source-output)-volume", _("#N VOLUME"));
@@ -1779,6 +1790,16 @@ int main(int argc, char *argv[]) {
             sink_name = pa_xstrdup(argv[optind+1]);
             port_name = pa_xstrdup(argv[optind+2]);
 
+        } else if (pa_streq(argv[optind], "set-default-sink")) {
+            action = SET_DEFAULT_SINK;
+
+            if (argc != optind+2) {
+                pa_log(_("You have to specify a sink name"));
+                goto quit;
+            }
+
+            sink_name = pa_xstrdup(argv[optind+1]);
+
         } else if (pa_streq(argv[optind], "set-source-port")) {
             action = SET_SOURCE_PORT;
 
@@ -1790,6 +1811,16 @@ int main(int argc, char *argv[]) {
             source_name = pa_xstrdup(argv[optind+1]);
             port_name = pa_xstrdup(argv[optind+2]);
 
+        } else if (pa_streq(argv[optind], "set-default-source")) {
+            action = SET_DEFAULT_SOURCE;
+
+            if (argc != optind+2) {
+                pa_log(_("You have to specify a source name"));
+                goto quit;
+            }
+
+            source_name = pa_xstrdup(argv[optind+1]);
+
         } else if (pa_streq(argv[optind], "set-sink-volume")) {
             action = SET_SINK_VOLUME;