Settings > Shortcuts: rebind the compositor's keyboard shortcuts
CI / test (push) Failing after 18s

- One shortcut table (compositor/shell/shortcuts.mbt): named actions with their default combos,
  the same as before: Super tap launcher, Super+D, Alt+Tab, Super+Shift+S, Super+Shift+Print,
  Print, Super+Print, Super+Ctrl+Print, Super+Shift+R, Super+Alt+R, Super+Ctrl+R. Combos are
  "Super+Ctrl+Alt+Shift+Key" text (parse/print, aliases like Meta, PrtSc, Return); "Super" alone
  is a Super tap. Two shortcuts on one combo conflict and the one listed first wins.
- The compositor looks every non-modifier key press up in the table (compositor/host/
  shortcuts.mbt) instead of the hardcoded checks in showdesktop/screenshot/recorder; the switcher
  reads its combo from it (hold the combo's modifiers, its key steps, Shift reverses, releasing a
  held modifier switches). Matching is now exact on Super/Ctrl/Alt/Shift (caps/num lock ignored),
  so e.g. Super+Shift+D or Ctrl+Print no longer fire Super+D / Print.
- Settings gets a fifth tab, Shortcuts (key 5, SettingsTab::Shortcuts): every shortcut and its
  combo. Click a row (or Enter) and press the new keys: the compositor captures the combo before
  anything else sees it (Escape cancels, Backspace unbinds, a Super tap binds "Super"; window
  switching keeps waiting until the combo has a modifier). Changed rows get a Reset button
  (Backspace/Delete on the highlighted row too), plus "Reset all to defaults"; conflicting combos
  show in red with a line saying which shortcut wins. The popup is 360 px wide for the fifth tab.
- New `shortcuts` capability (shortcuts, capture, cancel-capture, reset, reset-all), served from
  host table 10 and request 18 by the wasmer/wasmtime stub, host-wasm and the MoonBit wasmhost
  (chandra:host/plasmoids `shortcut(s32)`).
- Changes are kept in state.edn as :shortcuts {:show-desktop "Super+Ctrl+D" ...} (only the ones
  that differ; "" unbinds), applied at startup and live.
- There were no window-management or tiling key shortcuts to move into the table.
- Tests: combo parsing/printing, defaults, conflicts, switcher constraint, save/restore pairs,
  rebinding through the compositor, capture (Escape/Backspace/Super tap), the Shortcuts tab
  (capture, conflict line, Reset, Reset all) and the state.edn round trip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjypNwGHE9WeFvnWLA
This commit is contained in:
Claude committed 2026-11-25 20:41:22 +00:00
1 parent 8ecdef17d4
commit 34885bfdda
30 files changed
+1304 -149

No files matched your search

+31
View File
@@ -151,6 +151,37 @@ interface session-settings {
set-setting: func(index: u32, on: bool);
}
/// Keyboard shortcuts: the compositor's named actions (open the launcher, show the desktop, switch
/// windows, screenshots, recordings) and the key combo each is bound to. The shell keeps changed
/// combos in state.edn and they apply at once; a module with this capability (the settings
/// module's Shortcuts tab) lists and rebinds them.
interface shortcuts {
record shortcut {
/// What it does ("Show the desktop").
name: string,
/// Its combo as text, modifiers first ("Super+Shift+S"; "Super" alone is a tap of the Super
/// key); empty when unbound.
binding: string,
/// The combo it has by default.
default-binding: string,
/// The name of another shortcut on the same combo, or empty. The one listed first wins.
conflict: string,
/// Waiting for its new combo (see `capture`).
capturing: bool,
}
/// Every shortcut, in the order they are listed.
shortcuts: func() -> list<shortcut>;
/// Bind shortcut `index` to the next key combo pressed anywhere: the compositor takes that key
/// instead of acting on it. Escape cancels, Backspace unbinds. Window switching needs a combo
/// with a modifier (it keeps waiting otherwise).
capture: func(index: u32);
/// Stop waiting for a combo; the binding stays as it was.
cancel-capture: func();
/// Put shortcut `index` back to its default combo.
reset: func(index: u32);
reset-all: func();
}
/// Screenshots and screen recordings, after KDE Spectacle. The compositor captures (it alone sees
/// the screen); a module with this capability offers the modes and starts them.
interface screenshot {
+5 -1
View File
@@ -56,7 +56,8 @@ interface plasmoids {
/// (sssi: id name path loaded), 4 instances (sss: slot module name), 5 wallpapers (s), 6 session
/// settings (s), 7 icons (si: app id, raster image handle from `raster.load-image`) served by `icons.app-icon`,
/// 8 network status (one row, iissiiii: state signal name message wifi-enabled airplane
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved).
/// can-manage has-wifi), 9 Wi-Fi networks (siiii: ssid signal secured active saved), 10 keyboard
/// shortcuts (ssssi: name binding default-binding conflict capturing).
publish-table: func(which: u32, rows: list<u8>);
/// Layout mode (0 tiling, 1 monocle, 2 floating) and whether the Interface Explorer is on.
publish-state: func(layout-mode: s32, inspector-on: bool);
@@ -136,6 +137,9 @@ interface plasmoids {
power-action(s32),
network(network-request),
move-instance(instance-move),
/// The shortcuts capability: action * 1000 + index (0 capture, 1 reset, 2 reset all,
/// 3 cancel the capture).
shortcut(s32),
}
/// The next pending request, oldest first.
next-request: func() -> option<request>;
+3 -1
View File
@@ -83,6 +83,7 @@ world plasmoid-host {
import power;
import battery;
import network;
import shortcuts;
export plasmoid;
}
@@ -94,7 +95,7 @@ world logout-widget {
/// The settings module: session switches (restore, window places, dark mode), the wallpaper, the
/// panel's modules (load, unload, browse; the panel menu's "Modules..." opens that tab), and power
/// (idle timeouts, battery, suspend / restart / power off).
/// (idle timeouts, battery, suspend / restart / power off) and keyboard shortcuts (rebind, reset).
world session-settings-widget {
include widget;
import session-settings;
@@ -102,6 +103,7 @@ world session-settings-widget {
import modules;
import power;
import system;
import shortcuts;
}
/// Screenshot and screen recording launcher.