How to automatically set PulseAudio default sink to remote server at boot - Ubuntu 9.04

18,287

Solution 1

http://pulseaudio.org/wiki/DefaultDevice - default is not the same as fallback in PulseAudio. One can't really set a "default" device as described in the link within PulseAudio itself.

The "correct" way to do it would be to define a remote sink via module-tunnel-sink as you are trying to do. You say it is not possible on that version of PulseAudio, and then I can only recommend you to recheck syntax or upgrade in some way. Setting PULSE_SERVER can be done for login shells as in Gilles's answer. Below I write explicitly about my solution (with a recent PulseAudio version).

My exact lines from /etc/pulse/default.pa:

.ifexists module-tunnel-sink.so
.nofail
load-module module-tunnel-sink server=192.168.0.1 sink=alsa_output.pci-0000_00_1b.0.analog-stereo sink_name=d-f05
.fail
.endif

...just as you try to do. If this works, then you can set a "true default" via e.g. gnome-volume-control, where your aliased sink should show up as an available output device.

This way makes you able to switch output on the fly for all applications.

The definition of the remote sink can also be done nicer via Avahi, but I haven't been able to get that to work here just yet (not a PulseAudio problem).

Solution 2

The right place to set environment variables when you log in is, in most cases, ~/.profile.

~/.bashrc is a configuration file of the bash shell, read at startup by interactive instances of bash. It's not the right place to set an environment variable, because they would only be set in processes started from an interactive shell, as you've observed.

~/.profile is read by most login methods. However, depending on your distribution, display manager and session type, it may not be read when you log in in graphics mode. It is loaded in the default configuration on Ubuntu 10.04, but I'm not sure about 9.04. If it's not loaded, try ~/.gnomerc or ~/.xsession.

See also Difference between .bashrc and .bash_profile.

Share:
18,287

Related videos on Youtube

Dave M
Author by

Dave M

Updated on September 17, 2022

Comments

  • Dave M
    Dave M almost 2 years

    I use the Pulseaudio Device Chooser to set the default sink (on a laptop) to a remote server. This works fine. When i reboot my laptop, the default sink reverts back to "default" (the laptop sound card). Is there a way to get the laptop to continue to use the remote server after a reboot? Is there a command that I can run in a script on startup to change the default sink back to the remote server?

    I am running Ubuntu 9.04 on this machine.

    Looks like there is a problem creating the tunnel with the version of pulse used in the ubuntu 9.04 distribution. If I do the following on ubuntu 10.04 it works:

    pactl load-module module-tunnel-sink "server=192.168.1.64 sink=alsa_output.pci_8086_293e_sound_card_0_alsa_playback_0
    sink_name=sink-DGTM"
    
    pacmd set-default-sink sink-DGTM
    

    Unfortunately this does not work on ubuntu 9.04. The syslog shows:

    Nov 13 14:45:33 ubuntu-JMRT pulseaudio[3473]: module-tunnel.c: Stream died.

    So I am going to assume that there is a bug in this version of pulse. Although it does work with padevchooser, I can not get it to work from the command line. I also tried adding the following to /etc/pulse/default.pa and got the same results:

    load-module module-tunnel-sink server=192.168.1.64
    sink=alsa_output.pci_8086_293e_sound_card_0_alsa_playback_0 sink_name=sink-DGTM
    set-default-sink sink-DGTM
    

    syslog:

    Nov 13 14:45:33 ubuntu-JMRT pulseaudio[3473]: module-tunnel.c: Stream died.

    So I am back to trying to figure out where to export PULSE_SERVER so that apps launched from gnome see it when I reboot.

    I tried adding:

    export PULSE_SERVER=tcp:192.168.1.64:4713
    

    to: ~/.bashrc

    This works if I launch apps from the console but does not work if I launch apps from gnome.

    I also tried adding this export to:

    ~/.pulse/client.conf
    /etc/pulse/client.conf
    /usr/bin/start-pulseaudio-x11
    

    but none of the above worked.

    • Ignacio Vazquez-Abrams
      Ignacio Vazquez-Abrams over 13 years
      At boot, or on login?
    • Dave M
      Dave M over 13 years
      I think Ubuntu loads pulse at login?
  • Dave M
    Dave M over 13 years
    Adding "export PULSE_SERVER=tcp:192.168.1.64:4713" (where 192.168.1.64 is the IP address or DNS name of the remote pulse audio server) to ~/.profile works. Thank you.