From 50a5766d5158309c7ff1f52fc6edcc32ee480bc0 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 3 Nov 2025 04:55:45 +0100 Subject: [PATCH] kitty: add option `mouseBindings` (#8111) --- modules/programs/kitty.nix | 19 ++++++++++++++++++- .../kitty/example-mkOrder-expected.conf | 3 +++ .../programs/kitty/example-mkOrder.nix | 5 +++++ .../kitty/example-settings-expected.conf | 3 +++ .../programs/kitty/example-settings.nix | 5 +++++ .../kitty/null-shellIntegration-expected.conf | 1 + 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index b8f0157a0..96087ae78 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -42,6 +42,10 @@ let mkKeyValue = key: command: "map ${key} ${command}"; }; + toKittyMouseBindings = lib.generators.toKeyValue { + mkKeyValue = key: command: "mouse_map ${key} ${command}"; + }; + toKittyActionAliases = lib.generators.toKeyValue { mkKeyValue = alias_name: action: "action_alias ${alias_name} ${action}"; }; @@ -199,6 +203,18 @@ in ''; }; + mouseBindings = mkOption { + type = types.attrsOf types.str; + default = { }; + description = "Mapping of mouse bindings to actions."; + example = literalExpression '' + { + "ctrl+left click" = "ungrabbed mouse_handle_click selection link prompt"; + "left click" = "ungrabbed no-op"; + }; + ''; + }; + environment = mkOption { type = types.attrsOf types.str; default = { }; @@ -316,7 +332,8 @@ in (mkOrder 540 (toKittyConfig cfg.settings)) (mkOrder 550 (toKittyActionAliases cfg.actionAliases)) (mkOrder 560 (toKittyKeybindings cfg.keybindings)) - (mkOrder 570 (toKittyEnv cfg.environment)) + (mkOrder 570 (toKittyMouseBindings cfg.mouseBindings)) + (mkOrder 580 (toKittyEnv cfg.environment)) ]; xdg.configFile."kitty/kitty.conf" = { diff --git a/tests/modules/programs/kitty/example-mkOrder-expected.conf b/tests/modules/programs/kitty/example-mkOrder-expected.conf index 76ee85246..111b93aaa 100644 --- a/tests/modules/programs/kitty/example-mkOrder-expected.conf +++ b/tests/modules/programs/kitty/example-mkOrder-expected.conf @@ -19,5 +19,8 @@ action_alias launch_window launch --cwd=current --type=os-window map ctrl+c copy_or_interrupt map ctrl+f>2 set_font_size 20 +mouse_map ctrl+left click ungrabbed mouse_handle_click selection link prompt +mouse_map left click ungrabbed no-op + env LS_COLORS=1 diff --git a/tests/modules/programs/kitty/example-mkOrder.nix b/tests/modules/programs/kitty/example-mkOrder.nix index acc58287f..53dbd468b 100644 --- a/tests/modules/programs/kitty/example-mkOrder.nix +++ b/tests/modules/programs/kitty/example-mkOrder.nix @@ -25,6 +25,11 @@ "ctrl+f>2" = "set_font_size 20"; }; + mouseBindings = { + "ctrl+left click" = "ungrabbed mouse_handle_click selection link prompt"; + "left click" = "ungrabbed no-op"; + }; + actionAliases = { "launch_tab" = "launch --cwd=current --type=tab"; "launch_window" = "launch --cwd=current --type=os-window"; diff --git a/tests/modules/programs/kitty/example-settings-expected.conf b/tests/modules/programs/kitty/example-settings-expected.conf index 0a6afc926..0a039ac82 100644 --- a/tests/modules/programs/kitty/example-settings-expected.conf +++ b/tests/modules/programs/kitty/example-settings-expected.conf @@ -17,5 +17,8 @@ action_alias launch_window launch --cwd=current --type=os-window map ctrl+c copy_or_interrupt map ctrl+f>2 set_font_size 20 +mouse_map ctrl+left click ungrabbed mouse_handle_click selection link prompt +mouse_map left click ungrabbed no-op + env LS_COLORS=1 diff --git a/tests/modules/programs/kitty/example-settings.nix b/tests/modules/programs/kitty/example-settings.nix index 484dacda6..5383f2525 100644 --- a/tests/modules/programs/kitty/example-settings.nix +++ b/tests/modules/programs/kitty/example-settings.nix @@ -25,6 +25,11 @@ "ctrl+f>2" = "set_font_size 20"; }; + mouseBindings = { + "ctrl+left click" = "ungrabbed mouse_handle_click selection link prompt"; + "left click" = "ungrabbed no-op"; + }; + actionAliases = { "launch_tab" = "launch --cwd=current --type=tab"; "launch_window" = "launch --cwd=current --type=os-window"; diff --git a/tests/modules/programs/kitty/null-shellIntegration-expected.conf b/tests/modules/programs/kitty/null-shellIntegration-expected.conf index fedba1157..c1bcc986a 100644 --- a/tests/modules/programs/kitty/null-shellIntegration-expected.conf +++ b/tests/modules/programs/kitty/null-shellIntegration-expected.conf @@ -4,3 +4,4 @@ +