srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/ctl
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2026-05-13 19:47:00 +0200
committersrdusr <[email protected]>2026-05-13 19:47:00 +0200
commit670c9845129fc0c4b6e0192d657eea05e1a64b49 (patch)
tree273573d7ed109af3d39e268a6d43787b831c9d47 /crates/ctl
parent646b37e7e3aa5931079c6b9e804f420bb43c74d5 (diff)
downloadsrdwm-670c9845129fc0c4b6e0192d657eea05e1a64b49.tar.gz
srdwm-670c9845129fc0c4b6e0192d657eea05e1a64b49.zip
Expose key bindings over IPC so a launcher can list them
Asked whether srdwm's bindings show in the AGS launcher. They could not: srd.bind lives entirely in the Lua engine, and nothing published a binding anywhere a client could read it. There was no IPC command, no field in any response, and bound_keys() was used only by main.rs to register grabs. srd.bind now takes an optional third argument, a description, and the loaded set is copied into the WindowManager after the initial load and after every reload. Core neither owns nor interprets them - it has no Lua state and never dispatches a key - it holds them so the IPC layer, which is handed a WindowManager and nothing else, can serve them. New `srd keybindings` returns combo and description pairs, sorted so a UI listing them does not reshuffle on every refresh. Every binding in the shipped config now carries a description, so the feature is useful without the user writing any. Verified live in a nested instance: 46 bindings published, 0 without a description, and editing the config file updated the list without a restart (which also exercised reload-on-write again). Also verified, for the separate report that windows cannot be moved to another workspace from the AGS workspace pills: the compositor side works. `srd dispatch move workspace <id> 2` moved a window from workspace 1 to 2 and correctly hid it, since workspace 1 was active. Nothing to fix here; the missing piece is on the shell side. 515 tests pass, clippy clean.
Diffstat (limited to 'crates/ctl')
-rw-r--r--crates/ctl/src/main.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ctl/src/main.rs b/crates/ctl/src/main.rs
index 4689660..1153611 100644
--- a/crates/ctl/src/main.rs
+++ b/crates/ctl/src/main.rs
@@ -7,6 +7,7 @@
//! Usage:
//! srd clients list windows, one JSON object
//! srd workspaces list workspaces, one JSON object
+//! srd keybindings list key bindings and descriptions
//! srd settings current shadows/rounded_corners/
//! animations/night_light/reading_mode
//! state, one JSON object
@@ -144,6 +145,10 @@ fn build_request(args: &[String]) -> Result<String, String> {
Some("clients") => Ok(r#"{"cmd":"clients"}"#.to_string()),
Some("monitors") => Ok(r#"{"cmd":"monitors"}"#.to_string()),
Some("workspaces") => Ok(r#"{"cmd":"workspaces"}"#.to_string()),
+ // Every binding the loaded config registered, with its description
+ // if it gave one - what a launcher or cheat-sheet needs to show
+ // the user their own keys.
+ Some("keybindings") => Ok(r#"{"cmd":"keybindings"}"#.to_string()),
Some("settings") => Ok(r#"{"cmd":"settings"}"#.to_string()),
Some("pinned") if args.get(1).map(String::as_str) == Some("inputs") => Ok(r#"{"cmd":"pinned_inputs"}"#.to_string()),
Some("pinned") => Err("did you mean 'srd pinned inputs'?".to_string()),
@@ -221,7 +226,7 @@ fn build_request(args: &[String]) -> Result<String, String> {
Ok(format!(r#"{{"cmd":"set","key":"{key}","value":{value}}}"#))
}
_ => Err(
- "expected 'clients', 'monitors', 'workspaces', 'settings', 'keyboard layout', 'subscribe', 'dispatch <action> <id>', 'capture workspace <id> <path>', or 'set <key> <value>'"
+ "expected 'clients', 'monitors', 'workspaces', 'keybindings', 'settings', 'keyboard layout', 'subscribe', 'dispatch <action> <id>', 'capture workspace <id> <path>', or 'set <key> <value>'"
.to_string(),
),
}
@@ -409,6 +414,7 @@ fn print_usage() {
eprintln!(" srd clients");
eprintln!(" srd monitors");
eprintln!(" srd workspaces");
+ eprintln!(" srd keybindings");
eprintln!(" srd settings");
eprintln!(" srd pinned inputs");
eprintln!(" srd keyboard layout");