Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: how to control PulseAudio in command line?

  1. #1
    Join Date
    Feb 2009
    Location
    Riga, Latvia
    Beans
    22
    Distro
    Ubuntu 9.10 Karmic Koala

    Question how to control PulseAudio in command line?

    Hi. If I want to change the default sink of pulseaudio, I have to run padevchooser, then click on "other" in the "default sink" and enter the name of the sink I want to use.
    Is there a way to do this from command line? So it could be included in a script or sth..
    Maybe someone can suggest me where to look for pulse audio commands?

  2. #2
    Join Date
    Apr 2008
    Beans
    4,377
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    You can do that in pavucontrol.

    pacmd

    is the pulseaudio command. Try

    pacmd help

    for a list of options
    PMs will be ignored.

  3. #3
    Join Date
    Feb 2009
    Location
    Riga, Latvia
    Beans
    22
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    How do you exit pacmd?
    Last edited by natrixnatrix89; April 21st, 2009 at 11:37 PM.

  4. #4
    Join Date
    Feb 2009
    Location
    Riga, Latvia
    Beans
    22
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    pacmd really works, but i'd really like to know, how to use pacmd in a script, because
    Code:
    #!/bin/bash
    pacmd set-default-sink alsa_output.bluetooth
    or
    Code:
    #!/bin/bash
    pacmd set-default-sink
    alsa_output.bluetooth
    won't work.
    It would just open pacmd. Could anyone please tell me, what could be the syntax for bash script to run pacmd and then run a command in IT?

  5. #5
    Join Date
    Apr 2008
    Beans
    4,377
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    If you want to load modules into a running daemon from a script you can use

    pactl

    I have used it in scripts to load modules so I know it works for that.

    I am not sure if pactl can set defaults or even if setting default will do what you are expecting it to. Default will not redirect all your applications to your bluetooth headset for example if they have been opened on another device before.

    You could try commenting out the load-module module-volume-restore line in /etc/pulse/default.pa. That is the module that remembers where each application was last playing and restores it to that but then you will loose that function entirely.

    More on pactl here

    http://linux.die.net/man/1/pactl

    http://pulseaudio.org/wiki/Modules

    http://pulseaudio.org/wiki/FAQ
    PMs will be ignored.

  6. #6
    Join Date
    Feb 2009
    Location
    Riga, Latvia
    Beans
    22
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    pacmd set-default-sink worked perfectly fine in command line.
    What I want is to put it in a script.
    Is the conclusion that I can't use pacmd in a script?

  7. #7
    Join Date
    Apr 2008
    Beans
    4,377
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: how to control PulseAudio in command line?

    You probably can somehow but I do not know how, not being a big script fan.
    PMs will be ignored.

  8. #8
    Join Date
    Nov 2007
    Beans
    105

    Re: how to control PulseAudio in command line?

    Quote Originally Posted by natrixnatrix89 View Post
    pacmd set-default-sink worked perfectly fine in command line.
    What I want is to put it in a script.
    Is the conclusion that I can't use pacmd in a script?
    I found your thread because I was planning to do the same thing. Would be nice only have two steps to get BT rolling. However I notice that the man page for pacmd says it accepts no command line options which I believe is biting us in the butt. That would explain why the command isn't mentioned in the ~1500 threads I had to read to find the two that finally got my bluetooth headset working.

    At the very least it would be nice if paman would remember recent sink names so you don't have to enter it each time. =o/

  9. #9
    Join Date
    May 2009
    Beans
    4

    Re: how to control PulseAudio in command line?

    Hey, I was struggling with this too, and thought I was going to have to use expect or something like that, but I found a not-too-complicated solution: pipe the command through pacmd.

    For example --
    Code:
    echo "set-default-sink jack_out" |pacmd
    It doesn't cause pulseaudio to exit, and doesn't leave any pacmd processes lying around.

    Hope this works for you!

  10. #10
    Join Date
    Nov 2007
    Beans
    105

    Re: how to control PulseAudio in command line?

    Thank you landgrvi! Works great and now I can get my BT headset working in only two clicks. It almost qualifies as 'just works' although it's taken a lot of work to get there. heh

    For the record here is my 'enableHeadset' script

    Code:
    pactl load-module module-alsa-sink device=Headset; sleep 2
    pactl load-module module-alsa-source device=Headset; sleep 2
    echo "set-default-sink alsa_output.Headset" | pacmd
    echo "set-default-source alsa_input.Headset" | pacmd
    Last edited by RgnKjnVA; June 1st, 2009 at 03:23 AM.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •