Here is my little howto explaining how I configured my Linux box to select the audio device (so I can choose between my monitor, or my hifi setup for audio)

1. Pulse Audio

Pulse Audio currently only support Airplay devices through TCP protocol. For devices using UDP, like mine, you need to patch Pulse Audio to add UDP support. Patches are available on

Run PulseAudio paprefs program, go to 'Network Access' tab, and verify that option 'Make discoverable Apple AirTunes sound devices available locally' is enabled.

Run PulseAudio manager program, go to 'Devices' tab, and note the name of the various sinks devices. Your Airplay device should be listed there, if discovered. Here is mine for example:

 alsa_output.pci-0000_05_00.1.hdmi_stereo (video card HDMI output)
 alsa_output.pci-0000_00_1b.0.analog_stereo (PC jack output)
 raop_output.XC-HM71.local (Airplay device)

2. XBMC audio device switching script

Download here (it's a script I downloaded elsewhere, don't remember the original author though :( ).

You need to modify it to match your sinks listed above, at the start of the script:

def main():
    target_name = "alsa_output.pci-0000_00_1b.0.analog-stereo"
    target_vol = 100
    if sys.argv[1] == "2":
        target_name = "raop_output.XC-HM71.local"
        target_vol = 25
    if sys.argv[1] == "3":
        target_name = "alsa_output.pci-0000_05_00.1.hdmi-stereo"
        target_vol = 100

The target_vol option is used to force volume change when changing device, as many HiFi setups will not like volume being set to 100% as default (and neither you :) ). Of course you can add more devices, when ready, copy it to /usr/local/bin directory.

3. Configure XBMC hotkeys

Configure XBMC to use Pulse Audio for audio output. Now we need to configure hotkeys to use, to select the needed audio device. The file is $HOME/.xbmc/userdata/keymaps/keyboard.xml :


Then pressing F1, F2 or F3 will call the script with parameter 1,2 or 3, which will then tells PulseAudio to change the current audio output device.