
π Table of Contents
- πΆ Introduction
- β‘ Quick Start (TL;DR)
- π οΈ Setup & Installation (Ubuntu)
- π Automation Options
- π Cross-Platform Notes
- π οΈ Troubleshooting (Work in Progress)
- π Summary
πΆ Introduction
This guide shows you how to stream all system audio from Ubuntu to Sonos speakers using PipeWireβs built-in AirPlay/RAOP support.
Why would I want this?
- Works system-wide β everything from browsers, games, or media players gets sent to Sonos.
- Sonos speakers offer support for AirPlay, so it works with speakers that don’t offer Bluetooth, or AUX connection.
What is RAOP?
RAOP (Remote Audio Output Protocol) is the underlying tech behind Apple AirPlay 1.
PipeWire can discover RAOP devices like Sonos speakers and expose them as standard audio outputs in your Linux system.
And because AirPlay is Wifi based streaming, a connection to the same network as your speaker is the only requirement.
Whatβs covered in this guide?
- A Quick Start (TL;DR) for impatient users
- Step-by-step installation & setup on Ubuntu
- Automation options (auto-start at login or manual desktop launcher)
- Brief notes on Windows, macOS, and Android alternatives
- Troubleshooting tips (work in progress)
- Final summary/recap
β‘ Quick Start (TL;DR)
For users who just want the bare minimum to get Sonos working on Ubuntu.
# 1. Install required packages
sudo apt update
sudo apt install -y libspa-0.2-modules avahi-daemon pulseaudio-utils libnotify-bin
# 2. Enable Avahi (for mDNS device discovery)
sudo systemctl enable --now avahi-daemon
# 3. Restart PipeWire services
systemctl --user restart wireplumber
systemctl --user restart pipewire pipewire-pulse
# 4. Load RAOP discovery module
pactl unload-module module-raop-discover 2>/dev/null || true
pactl load-module module-raop-discover
# 5. Verify Sonos devices
pactl list short sinks | grep -i raop π If you see entries like “raop_output.Sonos-XYZ@...“, it works.
Open Settings β Sound β Output and select your Sonos.
From now on, all system audio is streamed to your Sonos over AirPlay.
π οΈ Setup & Installation (Ubuntu)
This section explains each step in detail, with context for what the commands do.
π¦ Step 1 β Install Required Packages
sudo apt update
sudo apt install -y libspa-0.2-modules avahi-daemon pulseaudio-utils libnotify-bin What each package does:
libspa-0.2-modulesβ adds the RAOP (AirPlay) plugin for PipeWireavahi-daemonβ runs mDNS/Bonjour discovery (Sonos auto-detection)pulseaudio-utilsβ provides thepactltool for managing moduleslibnotify-binβ providesnotify-sendfor desktop popups
π‘ Step 2 β Enable Avahi (mDNS Discovery)
sudo systemctl enable --now avahi-daemon enableβ ensures Avahi always starts at boot--nowβ launches it immediately
Without Avahi, Sonos devices cannot be discovered.
π Step 3 β Restart PipeWire Services
systemctl --user restart wireplumber
systemctl --user restart pipewire pipewire-pulse pipewireβ the audio serverpipewire-pulseβ PulseAudio compatibility layerwireplumberβ PipeWire session manager
Restarting ensures newly installed modules are loaded.
π Step 4 β Load RAOP (AirPlay) Discovery Module
pactl unload-module module-raop-discover 2>/dev/null || true
pactl load-module module-raop-discover - First line β removes any stale instance (ignores errors)
- Second line β loads the RAOP discovery module β scans your LAN for Sonos/AirPlay devices
β Step 5 β Verify Sonos Speakers
pactl list short sinks | grep -i raop Example output:
45 raop_output.Sonos-LivingRoom@192.168.0.50 module-raop-discover.c s16le 2ch 44100Hz π If you see entries like “raop_output.Sonos-XYZ@...“, it works.
Open Settings β Sound β Output and select your Sonos.
From now on, all system audio is streamed to your Sonos over AirPlay.
π Automation Options
Running RAOP discovery manually after every reboot can be tedious.
Here are three ways to automate or simplify the process:
βοΈ Option A β Automatic at Login (systemd user service)
Create a systemd service that runs at login:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/pipewire-raop.service Paste this:
[Unit]
Description=PipeWire RAOP (AirPlay) Sonos Discovery
After=pipewire.service pipewire-pulse.service wireplumber.service
[Service]
ExecStart=/usr/bin/pactl load-module module-raop-discover
Restart=on-failure
[Install]
WantedBy=default.target Enable and start:
systemctl --user daemon-reload
systemctl --user enable --now pipewire-raop.service π Your Sonos devices will now appear in Sound Settings automatically at login.
π±οΈ Option B β Manual Script + Desktop Launcher
If you prefer on-demand discovery, use a script and a desktop launcher.
1. Script
nano ~/Desktop/sonos-raop.sh Contents:
#!/usr/bin/env bash
pactl unload-module module-raop-discover >/dev/null 2>&1 || true
if pactl load-module module-raop-discover >/dev/null; then
notify-send "Sonos AirPlay aktiviert" "RAOP-Discovery lΓ€uft. WΓ€hle dein Sonos unter Sound-Ausgabe."
else
notify-send "Sonos AirPlay fehlgeschlagen" "Konnte RAOP-Discovery nicht laden."
fi Make it executable:
chmod +x ~/Desktop/sonos-raop.sh 2. Desktop Launcher
nano ~/Desktop/sonos-raop.desktop Contents:
[Desktop Entry]
Type=Application
Name=Sonos RAOP Discover
Exec=/home/YOURUSERNAME/Desktop/sonos-raop.sh
Icon=multimedia-volume-control
Terminal=false
Categories=AudioVideo;Utility; β Replace YOURUSERNAME with your actual username (e.g., max)..desktop files do not expand $HOME or $USER.
Make executable & trusted:
chmod +x ~/Desktop/sonos-raop.desktop
gio set ~/Desktop/sonos-raop.desktop "metadata::trusted" true 2>/dev/null || true π Double-clicking the launcher will trigger Sonos discovery with a popup notification.
π Option C β Hybrid
- Use Option A (systemd) for automatic startup
- Keep Option B (desktop launcher) as a fallback β one click rescans devices if they disappear after network changes
π Cross-Platform Notes
This guide is written for Ubuntu, but here are quick notes for other systems. (not tested!)
π§ Other Linux Distros
- Arch Linux / Manjaro
Install the required packages:
sudo pacman -S pipewire pipewire-pulse pipewire-alsa lib32-pipewire avahi
Then follow the same steps as Ubuntu (enable Avahi, restart PipeWire, load RAOP).
- Fedora / Red Hat / CentOS
Install via DNF:
sudo dnf install pipewire pipewire-pulseaudio pipewire-alsa avahi-tools
Then continue with Avahi + RAOP discovery as in this guide.
πͺ Windows
- Windows doesnβt have built-in system-wide AirPlay.
- You can use 3rd-party apps:
- TuneBlade β streams Windows audio to AirPlay devices
- Airfoil for Windows (paid) β similar solution
- Native Sonos app only streams music libraries/services, not system audio.
π macOS
- macOS has native AirPlay support.
- In System Preferences β Sound, select your Sonos speaker if it supports AirPlay 2.
- No extra software needed.
π± Android
- Android doesnβt support AirPlay out of the box.
- Use apps like AirMusic (supports AirPlay/RAOP, needs root or accessibility permissions).
- Alternatively, the Sonos app only streams music, not full system audio.
π οΈ Troubleshooting (Work in Progress)
Common issues and quick fixes. This section will be updated over time as new problems & solutions are discovered.
π No Sonos devices found?
systemctl status avahi-daemon
pactl unload-module module-raop-discover 2>/dev/null || true
pactl load-module module-raop-discover π Firewall blocks discovery?
Allow mDNS (UDP 5353):
sudo ufw allow 5353/udp π¬ Audio out of sync in videos?
- AirPlay adds ~200β300 ms delay.
- Fix by adjusting audio sync offset in your media player (e.g., VLC, mpv).
π More tips will be added here as users report issues or workarounds.
π Summary
- Installed required packages:
libspa-0.2-modules avahi-daemon pulseaudio-utils libnotify-bin - Enabled Avahi for Sonos/AirPlay device discovery
- Restarted PipeWire services
- Loaded the RAOP discovery module (
module-raop-discover) - Verified Sonos devices with:
pactl list short sinks | grep -i raop - Set up automation options:
- systemd user service β always active at login
- desktop script/launcher β manual trigger with notifications
- hybrid β best of both worlds
π With this setup, your Ubuntu machine can stream all system audio to Sonos over AirPlay with much lower latency than DLNA.
Wow! What a post.
π na is aber wirllich nice, ja!
Very well written and easy to follow guide! I am having a slight issue with playback upon completion of the last step. I can see my sonos devices listed in the sound settings and in the terminal. However upon trying to use the speaker, I’m met with silence and a minute or 2 later the speaker disappears from my sound settings and no longer appears in the list results in terminal.