FS#30926 - [pulseaudio] wrong entries in /etc/X11/xinit/xinitrc.d/pulseaudio

Attached to Project: Arch Linux
Opened by Heinrich Siebmanns (Harvey) - Monday, 30 July 2012, 18:37 GMT
Last edited by Jan Alexander Steffens (heftig) - Wednesday, 12 February 2014, 09:35 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Jan Alexander Steffens (heftig)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 3
Private No

Details

/etc/X11/xinit/xinitrc.d/pulseaudio tests for:
________________________________
#!/bin/bash

case "$DESKTOP_SESSION" in
gnome|kde*|xfce*|default) # PulseAudio is started via XDG Autostart
;;
*)
# Extra checks in case DESKTOP_SESSION is not set correctly
if [[ -z $KDE_FULL_SESSION && -z $GNOME_DESKTOP_SESSION_ID ]]; then
/usr/bin/start-pulseaudio-x11
fi
;;
esac
________________________________________
but the usual var in this context is DESKTOP_SESSION="default"

so the pulseaudio daemon get started by this script as well as the two (!) other entries
/etc/xdg/autostart/pulseaudio-kde.desktop
and also
nano /etc/xdg/autostart/pulseaudio-kde.desktop

resulting in two entries in /var/log/errors like this:
[pulseaudio] pid.c: Daemon already running
This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Wednesday, 12 February 2014, 09:35 GMT
Reason for closing:  Fixed
Additional comments about closing:  4.99.3-1, in [testing]
Comment by Heinrich Siebmanns (Harvey) - Tuesday, 31 July 2012, 08:24 GMT
This rather seems to be a problem of pulseaudio than a misconfigured login process for KDM. The env variable $DESKTOP_SESSION should be set to kde3/4 gnome2/3 and so on. 'Default' is not useful at all. Seems like other scripts rely on a consistent naming here too. Here is some code that tries to set the var to a more reasonable value: http://forum.porteus.org/viewtopic.php?f=81&t=816.
Comment by Heinrich Siebmanns (Harvey) - Tuesday, 31 July 2012, 12:50 GMT
I posted my edited version of /etc/X11/xinit/xinitrc.d/pulseaudio. I added 'default' to the first case. The original file says:
gnome|kde*|xfce*) # PulseAudio is started via XDG Autostart
and therefore skips the line because of $DESKTOP_SESSION = 'default'. By adding default to the case line it skips and lets pulseaudio get started via xdg startup from /etc/xdg/autostart/pulseaudio-kde.desktop which has
Exec=start-pulseaudio-kde
in it. So I got rid of one of the two "[pulseaudio] pid.c: Daemon already running" errors. After that I moved /etc/xdg/autostart/pulseaudio.desktop out of the path which has
Exec=start-pulseaudio-x11
in it and thus tries to start pulseaudio another time. Now the second "[pulseaudio] pid.c: Daemon already running" error is gone.
Pulseaudio runs and sound is o.k.
Done?
Comment by Jan Alexander Steffens (heftig) - Monday, 27 August 2012, 12:33 GMT
Where does this "default" come from? Everyone running KDE tells me it's "kde-plasma"
Comment by Heinrich Siebmanns (Harvey) - Monday, 27 August 2012, 17:58 GMT
I don't know. I just put an 'echo $DESKTOP_SESSION >> env_var.txt' into /etc/X11/xinit/xinitrc.d/pulseaudio to verify the content of the environment variable. The output is 'default' which explains the misbehaviour of the script. Try yourself.
Comment by Jan Alexander Steffens (heftig) - Monday, 27 August 2012, 18:28 GMT
Well, "default" is too generic to check.

Could I have a full environment dump, please?
Comment by Heinrich Siebmanns (Harvey) - Tuesday, 28 August 2012, 19:01 GMT
Of course. But you won't find it useful.

declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-Uvx4GXI1U2,guid=787a92047f0c2d755cb6da10503d1358"
declare -x DESKTOP_SESSION="default"
declare -x DISPLAY=":0"
declare -x DM_CONTROL="/var/run/xdmctl"
declare -x GTK_MODULES="canberra-gtk-module"
declare -x G_BROKEN_FILENAMES="1"
declare -x HOME="/home/harvey"
declare -x J2REDIR="/usr/lib/jvm/java-7-openjdk/jre"
declare -x J2SDKDIR="/usr/lib/jvm/java-7-openjdk"
declare -x JAVA_HOME="/usr/lib/jvm/java-7-openjdk"
declare -x LANG="de_DE.UTF-8"
declare -x LC_COLLATE="C"
declare -x LOGNAME="harvey"
declare -x MOZ_PLUGIN_PATH="/usr/lib/mozilla/plugins"
declare -x OLDPWD
declare -x PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin/core_perl"
declare -x PWD="/home/harvey"
declare -x SHELL="/bin/bash"
declare -x SHLVL="1"
declare -x USER="harvey"
declare -x WINDOWPATH="7"
declare -x XDG_CACHE_HOME="/home/harvey/.cache"
declare -x XDG_CONFIG_DIRS="/etc/xdg"
declare -x XDG_CONFIG_HOME="/home/harvey/.config"
declare -x XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
declare -x XDG_DATA_HOME="/home/harvey/.local/share"
declare -x XDG_SESSION_COOKIE="ec213935c21a498fa451a9891a73a9ca-1346179928.527312-1380516639"
declare -x XDM_MANAGED="method=classic"

I had this idea before too. But in the context of the executed script /etc/xdg/autostart/pulseaudio.desktop there is no env var that points to KDE. They all get set in the user context. If I do 'export' in a user context there is at least KDE_FULL_SESSION="true". But this seems to get set later than the execution of the pulseaudio script and therefore the fallback line
if [[ -z $KDE_FULL_SESSION && -z $GNOME_DESKTOP_SESSION_ID ]]; then
won't fire either.
Comment by Soup (Soup) - Saturday, 23 February 2013, 12:15 GMT
Before KDE 4.10 DESKTOP_SESSION=kde-plasma was set in env, it's now DESKTOP_SESSION=default. Not sure if it's how it's been packaged for Arch or if it's an upstream change.

Not very helpful, unfortunately.
Comment by Olivier Médoc (oliv) - Sunday, 17 March 2013, 08:38 GMT
Hello,

I have a very similar issue here.

I use a customized windows manager that has been developed by the Qubes-OS team. Meaning it's not gnome, nor kde, nor xfce. The problem is that this for-mentioned script has been changed to :
case "$DESKTOP_SESSION" in
gnome|kde*|xfce*) # PulseAudio is started via XDG Autostart
;;

This cause start-pulse-audio-x11 to starts, before xdg autostart targets. If 'default' cannot be used because kde broke the thing, I don't have any way to avoid pulseaudio to start except faking a gnome/kde desktop environment.

Is it possible to add some value like 'other' in order to allow users to bypass pulseaudio autostart ?

In fact, is this script needed at all ? Because it force users that installed pulseaudio to run pulseaudio.
Comment by Dave (DaveCode) - Monday, 28 October 2013, 21:22 GMT
Voted. Don't know what answers should be, but wish for closure after a year. Decide something and stick with it.

I think PulseAudio should autostart, unlike Olivier Médoc, since JACK interop is basically fixed (via dbus handshakes) and PulseAudio has a decent ALSA emulation backend. If it's installed, it should autostart.

But as I often run Openbox with a variety of apps from KDE and GNOME and elsewhere, not just stock desktop assumptions, I do find Arch scripts can fail to adequately address non-standard DEs. So I'm with Olivier there. Make script cases include unknown/undefined clauses.

An up-to-date KDE stock rig has empty $DESKTOP_SESSION while $KDE_FULL_SESSION gives "true" and meanwhile, perhaps unrelated, pavucontrol is core dumping all over me, sigh.
Comment by Colin Keenan (colinkeenan) - Saturday, 04 January 2014, 14:29 GMT
There is definitely something wrong with /etc/X11/xinit/xinitrc.d/pulseaudio, even when DESKTOP_SESSION is properly set.

I'm using Xfce and adding 'echo $DESKTOP_SESSION >> env_var.txt' into /etc/X11/xinit/xinitrc.d/pulseaudio shows that my DESKTOP_SESSION is correctly set to 'xfce'. Nevertheless, I'm getting an error on boot that pulseaudio is trying to start after it already started. I can prevent this error by moving one of the following files to my home directory: /etc/xdg/autostart/pulseaudio.desktop or /etc/X11/xinit/xinitrc.d/pulseaudio. This means both files are starting pulseaudio. I understand why /etc/xdg/autostart/pulseaudio.desktop is starting pulseaudio because that's what it's supposed to do when Xfce starts. But, why is /etc/X11/xinit/xinitrc.d/pulseaudio also starting pulseaudio? Here are the contents of /etc/X11/xinit/xinitrc.d/pulseaudio:
#!/bin/bash

case "$DESKTOP_SESSION" in
gnome|kde*|xfce*) # PulseAudio is started via XDG Autostart
;;
*)
# Extra checks in case DESKTOP_SESSION is not set correctly
if [[ -z $KDE_FULL_SESSION && -z $GNOME_DESKTOP_SESSION_ID ]]; then
/usr/bin/start-pulseaudio-x11
fi
;;
esac

I tried commenting out the "Extra checks" but that didn't solve anything.I tried replacing '/usr/bin/start-pulseaudio-x11' with 'touch /home/colin/tried-pulseaudio'. But it still started pulseaudio a 2nd time and it did not create /home/colin/tried-pulseaudio.

So why does moving /etc/X11/xinit/xinitrc.d/pulseaudio to my home directory solve the problem? It seems that if there's a file called pulseaudio in /etc/X11/xinit/xinitrc.d, it will try to start pulseaudio regardless of contents. I will test that out.
Comment by Colin Keenan (colinkeenan) - Saturday, 04 January 2014, 15:14 GMT
In my last comment, I said moving /etc/X11/xinit/xinitrc.d/pulseaudio to my home folder solved the problem, but on repeating that test, it doesn't solve the problem. Incredibly, I can move all three files that I thought could be responsible for starting pulseaudio, and it still starts! I moved /etc/X11/xinit/xinitrc.d/pulseaudio, /etc/xdg/autostart/pulseaudio.desktop, and /etc/xdg/autostart/pulseaudio-kde.desktop all to my home directory so those files were not in their usual places. Pulseaudio still started! There was no errors, but it still started. I just checked my .xinitrc and it doesn't have anything beyond executing stuff in /etc/X11/xinit/xinitrc.d.

It seems as though none of these files are necessary. How can I find out what is actually starting pulseaudio?
Comment by Colin Keenan (colinkeenan) - Tuesday, 07 January 2014, 17:30 GMT
I've discovered that even after deleting the xdg pulseaudio files and the xinitrc.d pulseaudio file, pulseaudio still starts when SDDM is enabled. If I disable SDDM, pulseaudio DOESN'T start. So the real cause for the double start of pulseaudio is that all the other files that start pulseaudio are not aware that the Display Manager also starts pulseaudio. Those files are designed so that ONLY ONE of them will ever start pulseaudio. Nevertheless, we still get a double start on pulseaudio because the Display Manager (SDDM in my case) is also starting pulseaudio. The xinitrc.d and xdg files need to test for the Display Manager, not just the Desktop, in order to avoid double start. Or, being aware of the issue, anyone using a Display Manager that they discover starts pulseaudio can simply delete all these other files.
Comment by Colin Keenan (colinkeenan) - Tuesday, 07 January 2014, 23:43 GMT
Please see  FS#38412  - [pulseaudio] pid.c: Daemon already running, Prevent by modifying ...xinitrc.d/pulseadio & PKGBUILD (https://bugs.archlinux.org/task/38412) that I have reported.

Loading...