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

Whit Blauvelt whit.pulse at transpect.com
Thu Sep 9 20:40:48 PDT 2010

> #! /usr/bin/expect
> spawn pacmd
> expect ">>>"
> send "set-default-source alsa_input.usb-Generic_FREETALK_Everyman_0000000001-00-Everyman.analog-stereo\r"
> expect ">>>"
> send "exit=\r"

Oops, that last line is triple wrong. Actually, the script as given works,
but it shouldn't. There's a typo of an added "=", and even worse there's the
use of "exit" which would be appropriate in many shells, but in pacmd tells
the utility to kill the daemon - not what's wanted, but it fortunately fails
to do that even with the "=" removed.

Happily, leaving that last line off entirely works. The script does need the
second expect line for ">>>" that's before it, for some reason. Then expect
gets out of the shell without an explicit exit or ctrl-C or whatever,

I'm sure the script could be expanded to also send the output somewhere
specific, or whatever. You could set up a whole row of buttons in your panel
to send system-specific commands, or groups of them, to pacmd via expect

Makes me feel a little better about the prospects of pulse, even if this is
way too hackish in its little way.


More information about the pulseaudio-discuss mailing list