A Discord Rich Presence IPC proxy that multiplexes RPC messages across multiple Discord instances.
presence-switch sits between Discord RPC client applications (games, media players, etc.) and running Discord instances. It binds the first available discord-ipc-{0..9} socket (preferring discord-ipc-0) and relays all incoming RPC messages to every other existing Discord IPC socket.
This means a single RPC client can broadcast its presence to multiple Discord clients simultaneously.
graph LR
A["RPC Client<br/>(e.g. game)"] --> B["presence-switch<br/>(discord-ipc-0)"]
B --> C["Discord #1"]
B --> D["Discord #2"]
B --> E["Discord #N"]
- The switch claims an available
discord-ipc-*socket name - RPC clients connect to the switch thinking it's Discord
- The switch relays messages to all real Discord instances on other sockets
The IPC binary protocol uses a simple format: 4-byte LE opcode + 4-byte LE length + UTF-8 JSON payload. The switch processes handshake, ping, and close opcodes directly, and forwards all other opcodes (frame, pong) to Discord.
- Rust (edition 2024)
- One or more running Discord instances
cargo build --release- Close Discord or ensure
discord-ipc-0is not taken - Run presence-switch:
cargo run --release
- Start your Discord instances β they will claim
discord-ipc-1,discord-ipc-2, etc. - Launch your RPC-enabled application β it connects to presence-switch on
discord-ipc-0, which relays to all Discord instances
For best results, start presence-switch before any Discord instances so it can claim discord-ipc-0, which is what most RPC clients connect to by default.
Press Ctrl+C to shut down gracefully.
| Platform | IPC mechanism |
|---|---|
| Linux | Unix domain sockets |
| macOS | Unix domain sockets |
| Windows | Named pipes |
Platform-specific implementations are selected at compile time via #[cfg].
src/
βββ main.rs
βββ switch/ # IPC server β accepts RPC client connections
β βββ ipc/
β βββ mod.rs # Server and Client logic
β βββ unix.rs # Unix domain socket listener
β βββ windows.rs # Named pipe listener
βββ discord/ # IPC client β connects to real Discord instances
βββ api.rs # Discord REST API for app metadata (cached)
βββ ipc/
βββ mod.rs # Client, protocol types, socket discovery
βββ unix.rs # Unix domain socket connection
βββ windows.rs # Named pipe connection