Skip to content

Improve xdg activation token integration - #9205

Open
jbms wants to merge 3 commits into
swaywm:masterfrom
jbms:activation-token-improvements
Open

Improve xdg activation token integration#9205
jbms wants to merge 3 commits into
swaywm:masterfrom
jbms:activation-token-improvements

Conversation

@jbms

@jbms jbms commented Jun 30, 2026

Copy link
Copy Markdown

The xdg activation token mechanism was designed primarily to prevent focus stealing, but also allows a "launch request" to be matched to the corresponding top-level window that is ultimately mapped as a result via the unique activation token. While not universally supported by all applications, it is now fairly widely supported.

This PR adds a number of related improvements to the existing support in sway for the activation token protocol:

  • Adds a mint_activation_token IPC command for creating a new activation token
  • Exposes initial_activation_token as a property in the JSON representation, to allow IPC clients to match a window with a corresponding launch request.
  • Adds initial_activation_token as a single-use, automatically cleaned up criteria.
  • Adds a for_exec_window command that runs an external program, like exec, and also specifies a list of sway commands to run on the window once it maps.

@jbms

jbms commented Aug 4, 2026

Copy link
Copy Markdown
Author

I think this pull request really adds some pretty valuable and widely applicable functionality --- it allows you to robustly launch a new application window, link it with a sway window id, and apply any number of commands (e.g. toggle floating). To my knowledge that is not something that can presently be achieved except through title matching and other unreliable heuristics. Even when using title matching as a heuristic, the title is often not set when the window is first committed.

@emersion I'd love to get you thoughts on this if you have a change to take a look.

jbms added 3 commits August 4, 2026 08:56
Implement for_exec_window <commands> <exec command> to run the list of
commands on the next window created by the executed process.
The window is matched based on the process ID (PID) of the spawned process.
- Add initial_activation_token criteria to match windows by their XDG
  activation token (or X11 startup ID).
- Expose initial_activation_token in the window JSON representation (get_tree).
Implement IPC_MINT_ACTIVATION_TOKEN (102) to request the compositor to
mint a new XDG activation token. Add corresponding support to swaymsg
and document it in the man pages and completions.
@jbms
jbms force-pushed the activation-token-improvements branch from 3293d91 to adef706 Compare August 4, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant