Hi, I have attached a slightly improved version of my original patch. It is still a hack but at least it won't just kill PA now without asking questions.
I have also thought about a more proper solution and have come up with a (IMHO) relatively good idea: I would basically write a new PA module called `module-x11-connect', which connects to X in a new thread when loaded and will crash PA once X is no longer available just like any other X application, see `basic_idea.c' for - well - a basic idea of just that. Anyway, before I continue working on this I'd like to get some opinions of the maintainters/upstream: a) Do you agree that PA should exit together with X if it was started as a session daemon? b) If the answer is yes, which is the best way to accomplish this? As always I am open for ideas and absolutely don't mind criticism! Best regards Alexander Kurtz
diff -ru old/usr/bin/start-pulseaudio-x11 new/usr/bin/start-pulseaudio-x11 --- old/usr/bin/start-pulseaudio-x11 2010-08-23 23:33:19.046983911 +0200 +++ new/usr/bin/start-pulseaudio-x11 2010-08-23 23:30:58.895484959 +0200 @@ -21,6 +21,13 @@ [ -z "$PULSE_SERVER" ] +# check if pulseaudio has already been started by someone else +if /usr/bin/pulseaudio --check; then + EXIT_WITH_X_SESSION=no +else + EXIT_WITH_X_SESSION=yes +fi + /usr/bin/pulseaudio --start "$@" if [ x"$DISPLAY" != x ] ; then @@ -32,3 +39,9 @@ /usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null fi fi + +# fork and wait for X-session to end, then quit pulseaudio +if [ "$EXIT_WITH_X_SESSION" = yes ]; then + /usr/bin/xprop -root -spy > /dev/null 2>&1 || true + /usr/bin/pulseaudio --kill +fi &
#include <X11/Xlib.h> #include <unistd.h> #include <pthread.h> void *pa_keep_x11_connection(){ Display *display = NULL; display = XOpenDisplay(NULL); for(;;){ XFlush(display); sleep(1); } } // this would be the main module function void main(){ pthread_t thread; pthread_create(&thread, NULL, pa_keep_x11_connection, NULL); // this is just to prevent the program from exiting immediatly sleep(3600); }
signature.asc
Description: This is a digitally signed message part