Galaxy Shell / docs
Docs / Interface e recursos

Keybinding table

openspec/specs/keybindings/spec.md · Editar no GitHub ↗

Esta página ainda não tem tradução em português. O conteúdo abaixo está em inglês.

Nesta página

Keybinding table

Purpose

Makes the remappable desktop keys a table of action ids to chords instead of matches in the compositor, with today's keys as the default and a lease so a vanished core cannot leave a changed table in force.

Requirements

Requirement: The compositor starts with working default keys

The compositor SHALL start with today's keys as the default table and keep working keys when it never hears from the core. The defaults are pinned in web-shell/test/fixtures/keybindings-defaults.json, read by a Rust test and a core test. Full text: section What it does.

Scenario: No core connected

  • WHEN the compositor never hears from the core
  • THEN the default keys work

Requirement: Fixed keys are outside the table

The table SHALL refuse the chords of the fixed keys, which the compositor checks before the table: the VT switch, the lock, quit, the overlay safe mode, the switcher, the screenshot keys, Ctrl+Alt with F1 to F12, every Escape behavior and the Super tap. Full text: section Fixed keys.

Scenario: Remap to Super+L

  • WHEN a command assigns Super+L to an action
  • THEN the command is refused

Requirement: No table key runs while locked

While the session is locked no table key SHALL run, and the compositor MUST refuse the command; only the control connection takes it, and the host connection gets the control connection message. Full text: section Fixed keys.

Scenario: Command while locked

  • WHEN the keybindings command arrives while locked
  • THEN it is refused

Requirement: Zoom actions act only in Canvas or Grid

The three zoom actions SHALL act only while the active workspace is in Canvas or Grid; elsewhere the chord reaches the client. The close action closes only the focused application window, never a shell window. Full text: section The actions.

Scenario: Zoom in a Focus layout

  • WHEN the active workspace is not Canvas or Grid and the zoom chord is pressed
  • THEN the chord reaches the client

Requirement: Chord format on the wire

A chord MUST be lowercase and plus-separated with modifiers in the order super, ctrl, alt, shift, each at most once, then one key name from the listed set; another spelling is refused, not normalized. A chord MUST always have Super. Full text: section The wire.

Scenario: Chord without Super

  • WHEN a binding chord is ctrl+c
  • THEN the command is refused

Requirement: Chord counts and refusals

An action SHALL have 1 to 4 chords and an empty list is refused; no chord may appear twice in the whole table. An unknown action id refuses the whole command, an omitted action takes its default, and a refused command keeps the current table. Full text: section The wire.

Scenario: Unknown action id

  • WHEN a command names an unknown action
  • THEN the whole command is refused and the table stays

Requirement: The core sends only what the compositor reports

The core SHALL send only the ids that the compositor reports, and send nothing while locked, while a request is pending, or when the reported table already matches. Full text: section The wire.

Scenario: Older compositor

  • WHEN the compositor does not report an id
  • THEN the core does not send that id

Requirement: The table is a lease

An accepted command SHALL take a lease for its control connection and a refused one does not. When the last connection that sent the table closes, the compositor waits the 60 s grace time and goes back to the default table. A non-default table goes out once on each new control connection, and while locked the core sends nothing. Full text: section When the core goes away.

Scenario: Core restarts within 60 s

  • WHEN the core reconnects within the grace time
  • THEN it renews the lease and no key flips

Requirement: Matching is exact

A key press SHALL match a chord when its modifiers are exactly those of the chord and its keysym is the key; an uppercase Latin letter folds to lowercase. Chords such as Super+Ctrl+Q no longer close a window and reach the client, and Super+Shift+Return no longer opens the terminal. Shift with a digit or a symbol gives the keysym of the layout, so such a chord is not in the key list. Full text: section Matching.

Scenario: Super+Ctrl+Q

  • WHEN the user presses Super+Ctrl+Q
  • THEN the chord reaches the client and no window closes

Scenario: Super+Shift+Return

  • WHEN the user presses Super+Shift+Return
  • THEN the terminal does not open and the chord reaches the client

Scenario: Shift with a digit

  • WHEN a chord is Super+Shift+1
  • THEN the key is the keysym of the layout (exclam on a US layout), so the chord is not in the key list

Requirement: Discoverability of the table

The Actions menu and the host labels of remappable keys (bars, overview, first-run card, settings, workspace tabs) SHALL show the first chord of each action from the table that the compositor reports, the default when it reports none. Full text: section Discoverability.

Scenario: Remapped key

  • WHEN the compositor reports a table that maps an action to another chord
  • THEN the menu and the visible controls of that action show the new chord

Requirement: Only the core and host reach the table

Only the core and the Electron host SHALL reach the control socket; no agent tool, MCP entry, scheduled turn, generated HTML or plugin panel reaches the table, the command or setKeybindings. Full text: section Authority.

Scenario: Plugin tries the command

  • WHEN a plugin panel tries to set the table
  • THEN it cannot reach the command

Status

Doc status: partly landed. Landed: the table in the compositor and the core, its sync and lease (2026-11-10); the profile file keybindings.json and the host labels from the table (2026-11-12). Not landed: a live check. Checked 2026-11-12.

What it does

The remappable desktop keys are a table of action ids to key chords instead of matches in native/smithay/src/input.rs. The compositor starts with today's keys as the default table (native/smithay/src/keybindings.rs), reports it in the state snapshot, and takes a new table from the core with the command keybindings (capabilities.keybindings). The core keeps its table in web-shell/core/keybindings.js and Smithay.setKeybindings, and syncKeybindings sends it while the compositor reports other chords, the pattern of hot-corners.md. Unlike the hot corners, the compositor does not start empty: a compositor that never hears from the core keeps working keys.

The actions

A closed list, with the ids of the Actions menu (web-shell/core/context-actions.js) where one exists. The defaults are pinned in web-shell/test/fixtures/keybindings-defaults.json, which a Rust test and a core test both read.

Id Default
overview Super+S
new_chat Super+N
terminal Super+Return
close Super+Q (the focused application window; never a shell window such as the chat, a bar or a panel)
workspace_previous, workspace_next Super+Left, Super+Right
workspace_1 to workspace_9, workspace_0 Super+1 to Super+9, Super+0 (workspace 10)
output_left, output_right Super+Shift+Left, Super+Shift+Right
focus_left ... focus_down Super+Alt+arrow
move_left ... move_down Super+Ctrl+arrow
resize_left ... resize_down Super+Ctrl+Alt+arrow
float Super+Shift+Space
fit_window Super+F
fill Super+G
focus_layout Super+T
layout_toggle Super+Shift+T
zoom_in Super+Plus, Super+Shift+Plus, Super+Equal
zoom_out Super+Minus
zoom_reset Super+Ctrl+0

The three zoom actions act only while the active workspace is in Canvas or Grid; elsewhere the chord reaches the client, as before.

Fixed keys

These keys are not in the table, the compositor checks them before it, and the table refuses their chords: the VT switch, the lock (Super+L and Super+Shift+L), quit (Super+Escape), the overlay safe mode (Super+Ctrl+Shift+R), the switcher (Alt or Super with Tab), the screenshot keys (Print, Shift+Print, Alt+Print), Ctrl+Alt with F1 to F12, every Escape behavior and the Super tap. Escape, Tab and Print are not key names of the table at all. While the session is locked no table key runs, as before, and the compositor refuses the command. Only the control connection takes the command: the host connection gets "The keybindings need the control connection", as for visual_style.

The wire

{ "action": "keybindings", "bindings": { "overview": ["super+o"], "close": ["super+w"] } }
  • A chord is lowercase and +-separated: the modifiers in the order super, ctrl, alt, shift, each at most once, then one key name: a to z, 0 to 9, f1 to f12, return, space, the four arrows, minus, equal, plus, comma, period, slash, semicolon, apostrophe, bracketleft, bracketright, backslash, grave, home, end, page_up, page_down, insert, delete and backspace. Another spelling is refused, not normalized.
  • A chord always has Super, so the table cannot swallow a key that a client needs for editing (Ctrl+C, Alt+Left). The VT switch and the other fixed chords stay refused.
  • An action has 1 to 4 chords; an empty list is refused, so no action loses its key. No chord appears twice in the whole table.
  • An unknown action id refuses the whole command. An action that the command omits takes its default. A refused command keeps the current table.
  • The state snapshot reports keybindings with every id the compositor knows. The core sends only the ids that the compositor reports, so an older compositor never gets an unknown id, and it sends nothing while locked, while a request is pending, or when the reported table already matches.

When the core goes away

The command is a lease, the pattern of visual_style (crate::canvas::Lease, Compositor::keybindings_lease). An accepted command takes it for its control connection; a refused one does not. When the last connection that sent the table closes, the compositor waits the 60 s of crate::canvas::GRACE and then goes back to the default table. The release runs through the shared control_connection_closed of native/smithay/src/ipc.rs. In the core the table is a ControlLease (web-shell/core/control-lease.js): a table other than the default goes out once on each new control connection, also when the report already matches, so a core restart within 60 s renews the lease and flips no key. While locked the core sends nothing, so a core that restarts behind a lock longer than 60 s finds the default table after the unlock and sends its own then. After a rollback to a core that never sends the table the defaults return once the grace time ends.

Matching

A key press matches a chord when its modifiers are exactly those of the chord and its keysym is the key; an uppercase Latin letter folds to lowercase, so Caps Lock and Shift still give Super+T and Super+Shift+T. This is stricter than before for two keys: Super+Ctrl+Q no longer closes a window and Super+Shift+Return (or with Ctrl or Alt) no longer opens the terminal; those chords now reach the client. Shift with a digit or a symbol gives the keysym of the layout (Super+Shift+1 is exclam on a US layout), so such a chord is not in the key list.

Discoverability

The Actions menu shows the first chord of each action from the table that the compositor reports (contextual-actions.md, Keybinding table). The labels of the bars (bars.jsx), the overview (workspace-overview.jsx), the first-run card (onboarding-tips.jsx), the settings (settings.jsx) and the workspace tabs (host.js) read wm.shortcuts, which the core builds from the reported table with the default per action (shortcutLabels). The fixed keys stay literal. The table comes from keybindings.json in the profile (openspec/changes/keybindings).

Authority

Only the core and the Electron host reach the control socket, as for hot_corners. No agent tool, MCP entry, scheduled turn, generated HTML or plugin panel reaches the table, the command or setKeybindings.