Problem: The user would like to run 'foo' server in conjunction with Pulseaudio in either gnome or kde without too much 'tinkering'. Tinkering means changing absolutely no files outside of /home without the aid of yum or some otherwise simple and reproducible command. Furthermore, these changes should work reliably across setups.
1) So in this case, the 'foo' server is jack. There are a number of programs I would like to work with that work with Jack instead of Pulse. Jack is essentially lower level than Pulse, so this solution is geared towards things that work underneath Pulse, thus tools that have to be running before Pulse is. Since jack is the defacto audio daemon for Freeeee and a favourite by the developers, Fedora users might want to become more familiar with it.
2) To the best of my knowledge, Gnome starts Pulseaudio by calling up the legacy ESD. Since Pulse wraps ESD nicely, it starts up instead using a systemwide default configuration. KDE on the other hand has a directory for systemwide and user specific start up scripts to be run. Pulse is included as a systemwide script. If the user is a member of pulse-rt, then it automatically uses realtime mode settings. Otherwise it resorts to defaults. We're assuming you want realtime settings.
# usermod -G pulse-rt
Nicely enough, we shouldn't need to do anything more for jack to run in realtime mode as well.
3) Although we can hack the KDE systemwide directories to start jackd as well, or just change the user specific ones, it provides no guarantees that jack can be started before pulse. Furthemore, this is not a possible solution for gnome.
When the user logins from gdm or kdm, the display manager searches for some .dekstop files that specify all the possible desktop environments available to the user. These .desktop files have links to different programs, such as 'gnome-session' or 'startkde'. These programs start up the comprehensive desktop environment. The user can also specify their own script or program to be run on the startup of the X server. This script is stored in a per-user basis at ~/.xsession . Although this is considered a 'legacy' method, it is quite commonly used in more minimalist setups. In order to enable this 'legacy' feature, run:
# yum install xorg-x11-xinit-session
Then create your ~/.xsession script.
$ vi ~/.xsession
and fill it with the following example
jackd --realtime -d alsa &
and finally make it executable
$ chmod +x ~/.xsession
Notice that in the .xsession file, the command for jackd has an ampersand '&' after it. This means that the program is run 'in the background'. gnome-session does not have the ampersand. When gnome-session is finished, then the X server dies. If you replace it with any other program, remember, once that program dies, the X server dies with it. (Try it with xterm or firefox, and see what happens when you close it down.)
You can of course experiment further with .xsession and put any programs you want to start, regardless of which DE you use.
4) Finally, Pulse must be configured to work with Jack. I used a config provided by jebba, one of the Freeeee developers. It goes in ~/.pulse/default.pa .
$ vi ~/.pulse/default.pa
Then fill it with this
load-module module-jack-sink channels=2 channel_map=front-left,front-right
#load-module module-jack-source channels=2 channel_map=front-left,front-right
## The following is not mandatory
## The following can conflict with this config.
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
### Load several protocols
# no workie
### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="martin RTP Multicast Sink"
load-module module-rtp-send source=rtp.monitor
### Publish connection data in the X11 root window
5) Finally, log out of your Gnome or KDE session, to come back to your login screen. Under 'session type' you should see a new option for 'Custom' next to KDE and Gnome. Login using that session type. Remember, Gnome or KDE will load up, depending on which you have put in .xsession . If you don't see that option, you may need to restart your computer, in order to restart your display manager. (If you're savy, you can just 'init 3' and then 'init 5' from the command line as root.)
6) One of the nice things about this configuration is that if either Pulse or Jack die, for any reason at all, you only need to open up a terminal and run the following commands.
$ killall pulseaudio ; killall jackd
$ jackd --realtime -d alsa & && pulseaudio &
Since they both now have sane default configurations, there is very little muck that has to be typed in at the command line to restart them.