Systemsound over Sonos (Linux/Ubuntu)

📑 Table of Contents

🎶 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 PipeWire
  • avahi-daemon → runs mDNS/Bonjour discovery (Sonos auto-detection)
  • pulseaudio-utils → provides the pactl tool for managing modules
  • libnotify-bin → provides notify-send for 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 server
  • pipewire-pulse → PulseAudio compatibility layer
  • wireplumber → 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.

Subscribe
Notify of
guest
2 Comments
Inline Feedbacks
View all comments
Jakob
Guest
Jakob
1 day ago
Reply to  Max Lechner

😂 na is aber wirllich nice, ja!

Scroll to Top