srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/crates/config/src
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2026-08-05 00:55:00 +0200
committersrdusr <[email protected]>2026-08-05 00:55:00 +0200
commit9c1673fa73bb49433370a60a7b4bb16abee98a9b (patch)
treed67c4e6187aee0229944900de9c1bf5c6095d20c /crates/config/src
parent3c47912ae0a2b81d06e4e9101b5b4e2f1e2997d9 (diff)
downloadsrdwm-9c1673fa73bb49433370a60a7b4bb16abee98a9b.tar.gz
srdwm-9c1673fa73bb49433370a60a7b4bb16abee98a9b.zip
Show a keybinding the way a person writes it, and let bind_repeat be described
Measured with dotfiles-1a, who own the launcher that displays these: `srd keybindings` returned 84 bindings and 84 empty descriptions - 100% - so every entry their launcher showed was a bare key combo with nothing to say what it does. Two causes, one on each side of the boundary. `srd.bind_repeat` never accepted a description. `srd.bind` has taken an optional third argument all along, but its repeating sibling took only two, and mlua drops a surplus argument silently rather than raising - so a config that documented its repeat bindings got no error and no description. It now takes one exactly like `bind`. The combos themselves were reported in their internal dispatch form: `Shift+Mod4+h`. `Mod4` is the X11 modifier's name, not a key's; nothing on a keyboard is labelled Mod4, and the canonical Ctrl/Shift/Alt/Mod4 ordering renders the owner's own `Super+Shift+h` binding back to them inside out. `srd keybindings` now reports a display form - Super, and the order people write - while everything internal keeps the canonical form it dispatches on. The display form parses back to the same binding, so it can be pasted into a config, and a test pins that round trip rather than trusting it. The owner's own config now describes all 84 bindings; verified through the real path, in a nested compositor running that config: 84 of 84 described, zero occurrences of "Mod4".
Diffstat (limited to 'crates/config/src')
-rw-r--r--crates/config/src/engine/general.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/crates/config/src/engine/general.rs b/crates/config/src/engine/general.rs
index 7c22747..05f0f66 100644
--- a/crates/config/src/engine/general.rs
+++ b/crates/config/src/engine/general.rs
@@ -102,10 +102,18 @@ impl Engine {
/// and window-switcher cycling, where one step per press is unusable.
pub(super) fn fn_bind_repeat(&self) -> Result<mlua::Function<'_>> {
let state = self.state.clone();
- Ok(self.lua.create_function(move |lua, (combo, f): (String, mlua::Function)| {
+ Ok(self.lua.create_function(move |lua, (combo, f, description): (String, mlua::Function, Option<String>)| {
let combo = srdwm_core::canonicalize_key_combo(&combo);
let key = lua.create_registry_value(f)?;
let mut s = state.borrow_mut();
+ // Takes a description exactly like `bind` does. It did not, and
+ // mlua drops the extra argument silently rather than raising --
+ // so a config that documented its repeat bindings got no error
+ // and no description, and every one of them showed up in a
+ // launcher as a bare key combo.
+ if let Some(description) = description.filter(|d| !d.trim().is_empty()) {
+ s.key_descriptions.insert(combo.clone(), description);
+ }
s.repeat_keys.insert(combo.clone());
s.key_bindings.insert(combo, key);
Ok(())