feat(discord-rpc): lazy Flatpak socket bridge keeps the integration opt-in
Discord-Flatpak writes its IPC socket to \$XDG_RUNTIME_DIR/app/com.discordapp.Discord/discord-ipc-N rather than the \$XDG_RUNTIME_DIR/discord-ipc-N path the discord-rich-presence crate searches by default. The naive way to bridge that gap — a startup wrapper that unconditionally symlinks every iteration before the binary launches — works, but it pulls the integration off-script: every other optional integration in QBZ (Last.fm, ListenBrainz, MusicBrainz, Plex) is opt-in, with zero telemetry and zero filesystem reach until the user flips the toggle. A startup wrapper would silently turn Discord RPC into opt-out at the sandbox layer; the symlinks would exist for users who never touched the integrations panel. Move the bridge into the lazy connect path instead. The first time the user actually connects — i.e. the first track plays after they enabled the toggle — prepare_flatpak_discord_socket_links runs: * No-op outside Flatpak (no FLATPAK_ID env var) * No-op when \$XDG_RUNTIME_DIR/discord-ipc-N already exists (native Discord, or a previous lazy run in this Flatpak instance) * No-op when the Discord-Flatpak source path doesn't exist (Discord not running) * Otherwise, symlinks 0..9 from \$XDG_RUNTIME_DIR/discord-ipc-N to \$XDG_RUNTIME_DIR/app/com.discordapp.Discord/discord-ipc-N Symlinks die with the Flatpak instance — \$XDG_RUNTIME_DIR is per- instance, so there's no cross-session pollution. Users who never enable Discord RPC keep the same sandbox surface as before. Manifest: keep the static xdg-run/discord-ipc-0 permission for native Discord, add xdg-run/app/com.discordapp.Discord:create so the lazy symlink path is allowed when the user opts in. The two coexist; the crate's default search path covers Discord-native, the symlinks cover Discord-Flatpak. cc
This commit is contained in:
2 files changed
+73
-1
No files matched your search
@@ -18,8 +18,19 @@ finish-args:
|
||||
# Native PipeWire access
|
||||
- --filesystem=xdg-run/pipewire-0:ro
|
||||
|
||||
# Discord IPC socket for Rich Presence (#336)
|
||||
# Discord IPC socket for Rich Presence (#336).
|
||||
# - The static path covers Discord installed natively (deb / rpm / AUR
|
||||
# builds), which write the socket directly under $XDG_RUNTIME_DIR.
|
||||
# - The :create permission on the Discord-Flatpak app dir lets us read
|
||||
# the socket created by Discord-via-Flathub AND lay down our own
|
||||
# $XDG_RUNTIME_DIR/discord-ipc-{0..9} symlinks pointing at it. The
|
||||
# crate `discord-rich-presence` only knows the static path; the
|
||||
# symlinks are what bridge the two sandboxes. See discord_rpc.rs:
|
||||
# prepare_flatpak_discord_socket_links — called only after the user
|
||||
# opts in via the settings toggle, so users who never enable Discord
|
||||
# RPC never touch this dir.
|
||||
- --filesystem=xdg-run/discord-ipc-0
|
||||
- --filesystem=xdg-run/app/com.discordapp.Discord:create
|
||||
|
||||
# User music library
|
||||
- --filesystem=xdg-music
|
||||
|
||||
Reference in new issue
Block a user