Miracast source for wlroots-based compositors
Stream your screen wirelessly to Miracast-compatible TVs and displays from Sway, River, Labwc, Hyprland, and other wlroots-based Wayland compositors.
# Clone repository
git clone https://github.com/forkline/swaybeam.git
cd swaybeam
# Build
just build
# Check system readiness
just doctor
# Run daemon (when all checks pass)
just daemonTip: Run
just --listto see all available commands.
| Component | Why Needed | Install (Arch) |
|---|---|---|
| Sway/River/Labwc/Hyprland | wlroots-based Wayland compositor | sway / river / labwc / hyprland |
| WiFi adapter with P2P | Wi-Fi Direct for Miracast | Hardware |
| PipeWire | Audio/video handling | pipewire wireplumber |
| GStreamer | H.264/H.265 encoding | gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly |
| NetworkManager | P2P connection management | networkmanager |
| xdg-desktop-portal-wlr | Screen capture | xdg-desktop-portal-wlr |
| just | Command runner (optional) | just |
# Install dependencies
sudo pacman -S --needed \
rust gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly \
pipewire wireplumber networkmanager wpa_supplicant \
xdg-desktop-portal xdg-desktop-portal-wlr
# Build and install
git clone https://github.com/forkline/swaybeam.git
cd swaybeam
just build
just installsudo apt install \
rustc cargo gstreamer1.0-plugins-base gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad gstreamer1.0-libav \
pipewire wireplumber network-manager wpa_supplicant \
xdg-desktop-portal-wlr
git clone https://github.com/forkline/swaybeam.git
cd swaybeam
just buildswaybeam doctorExpected output when ready:
✓ wlroots Compositor: Running under Sway/River/Labwc/Hyprland
✓ PipeWire: PipeWire daemon and session manager running
✓ GStreamer: H.264 ready, H.265/4K ready
✓ NetworkManager: NetworkManager daemon running
✓ WPA Supplicant: wpa_supplicant daemon running
✓ XDG Desktop Portal: xdg-desktop-portal running
swaybeam discover --timeout 10swaybeam connect --sink "Living Room TV"# 1080p (default)
swaybeam stream
# 4K at 30fps
swaybeam stream --width 3840 --height 2160 --framerate 30
# 4K at 60fps
swaybeam stream --width 3840 --height 2160 --framerate 60swaybeam disconnectswaybeam daemonThe daemon handles the full Miracast session automatically:
- Checks system requirements
- Discovers available sinks
- Connects via Wi-Fi Direct P2P
- Negotiates capabilities via RTSP
- Starts screen capture and streaming
- Handles disconnection gracefully
swaybeam doctor # Check system requirements
swaybeam discover [-t N] # Discover Miracast displays
swaybeam connect -s <name> # Connect to a display
swaybeam stream [options] # Start streaming
swaybeam disconnect # Disconnect from display
swaybeam daemon # Run full session
swaybeam status # Show connection status
| Codec | Resolution | Bitrate | Use Case |
|---|---|---|---|
| H.264 | 1080p | 8 Mbps | Universal compatibility |
| H.265 | 4K | 20 Mbps | Better quality for 4K TVs |
| AV1 | Any | 5 Mbps | Future-proof, best compression |
H.265 is automatically used for 4K streaming. H.264 is used for 1080p for maximum compatibility.
# Setup development environment
just setup
# Development workflow (lint-fix, test, build)
just dev
# Run tests
just test
# Run with debug logging
just debug daemon
# Quick check (lint and build, no tests)
just checkSee just --list for all available commands.
Install a WiFi adapter that supports P2P (Wi-Fi Direct). Most modern USB adapters work.
Swaybeam requires a wlroots-based Wayland compositor. Run under Sway, River, Labwc, Hyprland, or other wlroots compositors.
Install GStreamer plugins:
# Arch
sudo pacman -S gst-plugins-ugly
# Ubuntu
sudo apt install gstreamer1.0-plugins-uglyEnsure portal services are running:
systemctl --user start xdg-desktop-portal.service
systemctl --user start xdg-desktop-portal-wlr.service┌─────────────────────────────────────────────┐
│ CLI (swaybeam) │
└──────────────────────┬──────────────────────┘
│
┌──────────────────────▼──────────────────────┐
│ Daemon │
│ Orchestrates: discover, connect, stream │
└──────┬───────┬───────┬───────┬───────┬──────┘
│ │ │ │ │
Doctor Capture Stream Net RTSP
(check) (screen) (encode) (P2P) (WFD)
- ✅ System diagnostics (doctor)
- ✅ Wi-Fi Direct discovery (net)
- ✅ RTSP/WFD negotiation (rtsp)
- ✅ Screen capture via portal (capture)
- ✅ GStreamer H.264/H.265/AV1 encoding (stream)
- ✅ Session orchestration (daemon)
- ✅ CLI interface
- ⏳ Real hardware testing needed
MIT