[pulseaudio-discuss] Using "expect" to feed pacmd

Whit Blauvelt whit.pulse at transpect.com
Fri Sep 10 04:26:04 PDT 2010


On Fri, Sep 10, 2010 at 10:07:25AM +0100, Colin Guthrie wrote:

> Contrary to the comment that pacmd takes no command line options, you
> can just give it commands, so there is no need for this complicated
> expect script:
> 
> pacmd set-default-source alsa_input.usb-Generic_FREETALK_Everyman_0000000001-00-Everyman.analog-stereo
> 
> Should work fine.

You're right. It produces this visual noise, which doesn't look promising:

  Welcome to PulseAudio! Use "help" for usage information.
  >>> >>> 

But it does turn out to have done the job. The man page for pacmd does say:

  This program takes no command line options.

Evidently we're not supposed to RTFM on this one. Also, I've found the right
index numbers to use - the ones after /# in the listing of devices. But
those shouldn't be used, since in pulgging/unplugging they don't necessarily
come up the same.

> You mentioned earlier that it's "fragile", but this is entirely expected
> behaviour, so I'm not sure that that description is really appropriate.

Here's an example of fragility: the pacmd "exit" command doesn't follow the
standard *nix convention of "exit" exiting a shell. Instead it means what in
a *nix context shoudl be called "kill." So you use it. You discover you've
killed the daemon. Well, guess what. The daemon won't start again easily.
Trying /etc/init.d/pulseaudio start or just pulseaudio& - neither gets it
started. Neither gives a decent error message as to why it fails, either to
console or logs. You end up rebooting the system. Okay that works. 

Maybe this is a problem with Canonical's version of the init.d/pulseaudio
script. But there are _lots_ of ways to get the pulseaudio stack into a
condition where it pretty much requires a system reboot. That's Windows-ish.
*nix programs should be more robust than that.

Best,
Whit



More information about the pulseaudio-discuss mailing list