diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-29 11:52:52 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-29 11:52:52 +0200 |
commit | 708056676a639f58c508c34fe986d3c73f11488f (patch) | |
tree | 7268f0c0f3d7bbb2840732bcd7dd9f4325a2df6f /pkgs | |
parent | modules/river: Use the same keymap for both tiamat and apzu (diff) | |
download | nixos-config-708056676a639f58c508c34fe986d3c73f11488f.zip |
{modules/river,pkgs/river-mk-keymap}: Support keymap descriptions
That just avoids the visual clutter, caused by the nix store paths.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/by-name/ri/river-mk-keymap/contrib/init.json | 5 | ||||
-rw-r--r-- | pkgs/by-name/ri/river-mk-keymap/src/key_map/mod.rs | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/pkgs/by-name/ri/river-mk-keymap/contrib/init.json b/pkgs/by-name/ri/river-mk-keymap/contrib/init.json index 7faaeb43..a5f24307 100644 --- a/pkgs/by-name/ri/river-mk-keymap/contrib/init.json +++ b/pkgs/by-name/ri/river-mk-keymap/contrib/init.json @@ -113,10 +113,13 @@ ] }, "m": { - "l": [ + "l": { + "command": [ "spawn", "/nix/store/7h9w2sycqj3i2lp61nibgv7qhvwy3pi9-wireplumber-0.5.10/bin/wpctl set-volume @DEFAULT_SINK@ 5%-" ], + "description": "wpctl set-volume @DEFAULT_SINK@ 5%-" + }, "m": [ "spawn", "/nix/store/08bgv5x7gfhkczf0lgrpim1rw51jlxvn-mpp/bin/mpp toggle" diff --git a/pkgs/by-name/ri/river-mk-keymap/src/key_map/mod.rs b/pkgs/by-name/ri/river-mk-keymap/src/key_map/mod.rs index 60ed41b8..5c89c2e2 100644 --- a/pkgs/by-name/ri/river-mk-keymap/src/key_map/mod.rs +++ b/pkgs/by-name/ri/river-mk-keymap/src/key_map/mod.rs @@ -29,6 +29,9 @@ pub struct KeyConfig { /// Whether to allow this key mapping in the “locked” mode. #[serde(default)] allow_locked: bool, + + /// Use a different description to display this command, instead of the `command`. + description: Option<String>, } impl FromStr for KeyMap { @@ -48,6 +51,7 @@ impl FromStr for KeyMap { .collect::<Option<_>>() .ok_or(anyhow!("A array contained a non-string value: {value:#?}"))?, allow_locked: false, + description: None, } } else if let Some(object) = value.as_object() { if object.contains_key("command") { @@ -100,7 +104,11 @@ impl FromStr for KeyMap { } impl Display for KeyConfig { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(self.command.join(" ").as_str()) + if let Some(desc) = &self.description { + f.write_str(desc) + } else { + f.write_str(self.command.join(" ").as_str()) + } } } |