Skip to content

Linux: Open terminal reaches the session's window on niri - #1156

Open
untypequicode wants to merge 1 commit into
Louis-CFM:mainfrom
untypequicode:niri-focus-window
Open

untypequicode wants to merge 1 commit into
Louis-CFM:mainfrom
untypequicode:niri-focus-window

Conversation

@untypequicode

Copy link
Copy Markdown

What

On niri, "Open terminal" found no window to bring forward: niri is a Wayland compositor without the KWin door, and EWMH only reaches XWayland windows. This adds niri as a third way in platform/linux_focus.rs.

  • niri msg --json windows lists every window with its process ID, native Wayland ones included.
  • The window of the nearest ancestor is picked with the existing session_window::choose_window (the one titled after the session's folder when a process has several).
  • niri msg action focus-window --id <id> scrolls to it and switches to its workspace.

The niri way is taken only when NIRI_SOCKET is set in a Wayland session, and comes before the X11 way, which stays as a second try for XWayland windows. Nothing changes on other desktops.

As with the other ways, the only values handed to a command are numbers we read ourselves (the window id from niri's own answer), passed as separate arguments, never through a shell.

Scope

Kept to the minimum: one file of Rust and the "Open terminal" list in windows/README.md. An Unreleased entry is in the CHANGELOG.

Tests

  • methods() cases for niri (native and XWayland, and a stale NIRI_SOCKET outside Wayland).
  • niri::pick on a sample of niri msg --json windows: the folder's window wins, entries without a pid or with a bad id are skipped, garbage gives nothing.
  • cargo test -p coucou linux_focus: 8 passed. The JSON shape was checked against niri 26.04.

🤖 Generated with Claude Code

… CHANGELOG

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant