srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/platform
diff options
context:
space:
mode:
Diffstat (limited to 'crates/platform')
-rw-r--r--crates/platform/src/ipc/dispatch.rs11
-rw-r--r--crates/platform/src/ipc/types.rs14
2 files changed, 25 insertions, 0 deletions
diff --git a/crates/platform/src/ipc/dispatch.rs b/crates/platform/src/ipc/dispatch.rs
index 749b2aa..ad79b98 100644
--- a/crates/platform/src/ipc/dispatch.rs
+++ b/crates/platform/src/ipc/dispatch.rs
@@ -417,6 +417,17 @@ pub(crate) fn handle_request(line: &[u8], wm: &std::rc::Rc<std::cell::RefCell<Wi
// `redraw_decoration`/`apply_geometry` for every visible window
// unconditionally - this only has to mutate the right field and
// let that existing machinery do the rest.
+ // `{"cmd":"keybindings"}` - every binding the loaded config
+ // registered, as `(combo, description)`. Read-only, and the one
+ // way a panel or launcher can show the user what their own keys
+ // do: `srd.bind` lives entirely in the Lua engine, so nothing
+ // outside this process could see a binding at all before this.
+ "keybindings" => {
+ let wm = wm.borrow();
+ let list: Vec<KeybindingInfo> =
+ wm.keybindings.iter().map(|(combo, description)| KeybindingInfo { combo: combo.clone(), description: description.clone() }).collect();
+ (serde_json::to_vec(&KeybindingsResponse { keybindings: list }).unwrap_or_default(), false)
+ }
"set" => handle_set(&req, wm),
_ => (err("unknown command"), false),
}
diff --git a/crates/platform/src/ipc/types.rs b/crates/platform/src/ipc/types.rs
index f9af26c..286df20 100644
--- a/crates/platform/src/ipc/types.rs
+++ b/crates/platform/src/ipc/types.rs
@@ -122,6 +122,20 @@ pub(crate) struct MonitorsResponse {
pub(crate) monitors: Vec<MonitorInfo>,
}
+/// One key binding, for `srd keybindings`. `description` is empty when the
+/// binding did not give one - an empty string rather than `null`, so a
+/// consumer can render it without a branch.
+#[derive(Serialize)]
+pub(crate) struct KeybindingInfo {
+ pub(crate) combo: String,
+ pub(crate) description: String,
+}
+
+#[derive(Serialize)]
+pub(crate) struct KeybindingsResponse {
+ pub(crate) keybindings: Vec<KeybindingInfo>,
+}
+
#[derive(Serialize)]
pub(crate) struct WorkspacesResponse {
pub(crate) workspaces: Vec<WorkspaceInfo>,