You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Linux: open-URL and reopen hook via org.freedesktop.Application #22
On macOS, an app receives "open URL" and "reopen" (Dock click or relaunch while running) events. Linux apps need the equivalent so that relaunching a running app reuses the existing instance, and URL or file activation reaches it.
Needed: an app-level hook for open-URL/open-files and reopen, with one API across platforms. On Linux, implement the D-Bus org.freedesktop.Application interface (Activate, Open, ActivateAction) with single-instance handling on the session bus, and pass the activation token through to the shown window. Check against the existing macOS lifecycle hooks so the API is shared.
Implemented the Linux half in PR #29 (commit 35329d7, crates/rune/src/instance.rs + App::single_instance / App::on_open):
First launch owns rune.<app_id> on the session bus (zbus service role); second launch probes NameHasOwner (no stray Activate queued), forwards files/URIs via org.freedesktop.ApplicationOpen (or bare Activate), and exits 0 before any window opens.
Owner drains the queue on the event thread through on_open(&[String]); empty URIs act as on_reopen. No bus → runs unclaimed; headless never claims.
Gotcha found while testing: a leaked serving connection alone is not enough — with no executor left, the owner's method calls never dispatch and the second launch hangs. The owner now serves on a dedicated bus thread for the app's life.
E2E: cargo test -p rune --lib instance — bus-name shaping unit + two live session-bus round-trips (Open-forward with 2 URIs landing in the owner's queue; bare Activate as empty reopen), green in 0.04s.
Activation tokens: XDG_ACTIVATION_TOKEN/DESKTOP_STARTUP_ID is captured on the forwarded request; passing it through to the shown window rides the existing AppHandle::activate(token) path (the owner's on_open handler calls it) — same mechanism the X11/Wayland window code already uses.
Thanks, this makes sense. Some of it is already in Rune, so here's what's there and what's missing.
Already there (Linux):rune::single_instance(id) keeps one process per app over a Unix socket in $XDG_RUNTIME_DIR (crates/rune/src/open_url/instance/linux.rs). A later launch hands its arguments to the running process: its links go to App::on_open_url, and a launch without links runs on_reopen and its default. The doc comments on on_open_url and on_reopen in app.rs still say they never run on Linux, so they need updating.
Missing, and what this issue would add:
An org.freedesktop.Application server on the session bus (Activate, Open, ActivateAction), so DBusActivatable=true desktop entries and launchers that go over D-Bus reach the running instance. It also needs to fit with the socket handoff that's already there.
File opens on Linux: App::on_open_files never runs there today, so Open with file:// URIs, or file paths passed as launch arguments, should reach it, as on macOS.
The activation token: the launch's activation-token / desktop-startup-id platform data, or XDG_ACTIVATION_TOKEN / DESKTOP_STARTUP_ID, should be passed along to the window that gets shown so the compositor lets it take focus. Nothing in the handoff passes it along yet.
Keeping one set of hooks across platforms (on_reopen, on_open_url, on_open_files) rather than adding a Linux-only one.
I've opened a PR that adds this on Linux, using the same hooks as macOS and Windows:
With rune::single_instance(id), the first process also owns id on the session bus and serves org.freedesktop.Application.
Activate and ActivateAction run App::on_reopen. Rune has no named actions, so the action's name isn't passed on.
Open sends links to App::on_open_url and file:// URIs to App::on_open_files.
Launch arguments are sorted the same way. A desktop entry's %U file URIs reach on_open_files, from the first launch and from later ones handed to the running app. Plain paths (%F) aren't passed on to a running app, so use %U.
A later launch's activation token, from XDG_ACTIVATION_TOKEN / DESKTOP_STARTUP_ID or the call's activation-token, goes to the window the launch brings forward, or else to the next window the app opens. A launch that has to start the app again passes both its URIs and its token to the new process.
id has to be a valid bus name. DBusActivatable=true also needs a desktop entry named <id>.desktop and a session service file; the README now says how.
The tests cover the URI and token handling and how launches are routed. It hasn't been tried against a real session bus or built for Windows yet.
Activity
ImBIOS commentedon Oct 26, 2026
Implemented the Linux half in PR #29 (commit
35329d7,crates/rune/src/instance.rs+App::single_instance/App::on_open):rune.<app_id>on the session bus (zbusservice role); second launch probesNameHasOwner(no stray Activate queued), forwards files/URIs viaorg.freedesktop.ApplicationOpen(or bareActivate), and exits 0 before any window opens.on_open(&[String]); empty URIs act ason_reopen. No bus → runs unclaimed; headless never claims.E2E:
cargo test -p rune --lib instance— bus-name shaping unit + two live session-bus round-trips (Open-forward with 2 URIs landing in the owner's queue; bare Activate as empty reopen), green in 0.04s.Activation tokens:
XDG_ACTIVATION_TOKEN/DESKTOP_STARTUP_IDis captured on the forwarded request; passing it through to the shown window rides the existingAppHandle::activate(token)path (the owner'son_openhandler calls it) — same mechanism the X11/Wayland window code already uses.Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
GNOME overlay fallback; single-instance token/show path
Linux icons: session-theme + Inherits lookup; single instance via org…
GNOME overlay fallback; single-instance token/show path
Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
Linux icons: session-theme + Inherits lookup; single instance via org…
opencodejr commentedon Nov 25, 2026
Thanks, this makes sense. Some of it is already in Rune, so here's what's there and what's missing.
Already there (Linux):
rune::single_instance(id)keeps one process per app over a Unix socket in$XDG_RUNTIME_DIR(crates/rune/src/open_url/instance/linux.rs). A later launch hands its arguments to the running process: its links go toApp::on_open_url, and a launch without links runson_reopenand its default. The doc comments onon_open_urlandon_reopeninapp.rsstill say they never run on Linux, so they need updating.Missing, and what this issue would add:
org.freedesktop.Applicationserver on the session bus (Activate,Open,ActivateAction), soDBusActivatable=truedesktop entries and launchers that go over D-Bus reach the running instance. It also needs to fit with the socket handoff that's already there.App::on_open_filesnever runs there today, soOpenwithfile://URIs, or file paths passed as launch arguments, should reach it, as on macOS.activation-token/desktop-startup-idplatform data, orXDG_ACTIVATION_TOKEN/DESKTOP_STARTUP_ID, should be passed along to the window that gets shown so the compositor lets it take focus. Nothing in the handoff passes it along yet.on_reopen,on_open_url,on_open_files) rather than adding a Linux-only one.opencodejr commentedon Nov 25, 2026
I've opened a PR that adds this on Linux, using the same hooks as macOS and Windows:
rune::single_instance(id), the first process also ownsidon the session bus and servesorg.freedesktop.Application.ActivateandActivateActionrunApp::on_reopen. Rune has no named actions, so the action's name isn't passed on.Opensends links toApp::on_open_urlandfile://URIs toApp::on_open_files.%Ufile URIs reachon_open_files, from the first launch and from later ones handed to the running app. Plain paths (%F) aren't passed on to a running app, so use%U.XDG_ACTIVATION_TOKEN/DESKTOP_STARTUP_IDor the call'sactivation-token, goes to the window the launch brings forward, or else to the next window the app opens. A launch that has to start the app again passes both its URIs and its token to the new process.idhas to be a valid bus name.DBusActivatable=truealso needs a desktop entry named<id>.desktopand a session service file; the README now says how.The tests cover the URI and token handling and how launches are routed. It hasn't been tried against a real session bus or built for Windows yet.
Fixed in #2216.
Let a modal that closes on an outside press pass that press to what i…