2

So I'm writing aliases so that I can start/stop pulseaudio for the purpose of running some Wine apps. My aliases currently look like:

# Reload pulse audio devices
alias rldpulsdev='sudo service avahi-daemon restart'

#Wine needs to use ALSA directly. PulseAudio interferes with it.
#kill pulseaudio
alias kpa='echo "autospawn = no" > ~/.config/pulse/client.conf;sudo service pulseaudio stop'
#start pulseaudio
alias spa='echo "autospawn = yes" > ~/.config/pulse/client.conf;sudo service pulseaudio start;rldpulsdev'

Problem: If I kill pulseaudio using the above alias, all of the devices disappear from the sound management widget and the speaker icon disappears from the tray. That's OK for when pulse is off but I want the start alias to fix this. The "rldpulsdev" alias above is part of the puzzle but I'm definitely still missing something. Clue please? If I fiddle around with it and maybe restart or relog, it fixes itself eventually but this in itself implies there's something I can do to fix it from an alias.

  • I don't remember the details but there was some reason we couldn't use it. I'll see if I can find out what it was. – user447607 Mar 10 '15 at 18:07
  • Thanks. Actually that's a lesson I learned just yesterday but the aliases have not yet been updated. – user447607 Mar 11 '15 at 04:31
  • This might be why. https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/944295 Anyway this is off topic. The objective is to refresh the devices in the sound widget. – user447607 Mar 11 '15 at 05:14
  • Woohoo!! That did it! I think I understand this now. You have to use the userland stuff if you want avahi to re-display the devices. @Takkat Reformulate as a solution and I will select. – user447607 Mar 11 '15 at 05:27

1 Answers1

0

On Ubuntu Pulse Audio is designed to run in userspace. Running Pulse Audio as a service in system wide mode is possible but not recommended as it may cause too many other issues, and other applications in userpace (e.g. Avahi) or applications that rely on pulseaudio in userspace can not communicate with the sound server.

Only in case we run Pulse Audio as a user configuration files in ~/.config/pulse/ will be read. Otherwise only settings from /etc/pulse are valid. Therefore any changes to settings of Pulse Audio running in system-wide mode can not be defined in any user's HOME.

The recommended way to temporarily suspend pulseaudio for running Wine with ALSA would be:

pasuspender -- wine <options) <windows-program>

To stop pulseaudio running as a user we can issue

pulseaudio -k

This can also be included in a script or alias. Per default pulseaudio will then immediately respawn. If we had disabled this we start pulseaudio simply by

pulseaudio

Settings from ~/.config/pulse will overriding global settings in /etc/pulse if present. Note that we do not need (and should not use) root permissions for both commands.

Takkat
  • 142,284