From 85748171ec0dc78fea92240d1c3f8f34713ed874 Mon Sep 17 00:00:00 2001 From: Roman Volosatovs Date: Sat, 30 May 2020 13:58:05 +0200 Subject: [PATCH] sway: add option `config.bindkeysToCode` Do not use `--to-code` by default in `bindsym`. PR #1289 --- modules/services/window-managers/i3-sway/i3.nix | 2 +- .../window-managers/i3-sway/lib/functions.nix | 6 +++--- modules/services/window-managers/i3-sway/sway.nix | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/services/window-managers/i3-sway/i3.nix b/modules/services/window-managers/i3-sway/i3.nix index 202a97978..540025055 100644 --- a/modules/services/window-managers/i3-sway/i3.nix +++ b/modules/services/window-managers/i3-sway/i3.nix @@ -180,7 +180,7 @@ let client.placeholder ${colorSetStr colors.placeholder} client.background ${colors.background} - ${keybindingsStr keybindings} + ${keybindingsStr { inherit keybindings; }} ${keycodebindingsStr keycodebindings} ${concatStringsSep "\n" (mapAttrsToList modeStr modes)} ${concatStringsSep "\n" (mapAttrsToList assignStr assigns)} diff --git a/modules/services/window-managers/i3-sway/lib/functions.nix b/modules/services/window-managers/i3-sway/lib/functions.nix index 31d314b04..ea2938e6f 100644 --- a/modules/services/window-managers/i3-sway/lib/functions.nix +++ b/modules/services/window-managers/i3-sway/lib/functions.nix @@ -8,10 +8,10 @@ rec { concatStringsSep " " (mapAttrsToList (k: v: ''${k}="${v}"'') criteria) }]"; - keybindingsStr = keybindings: + keybindingsStr = { keybindings, bindsymArgs ? "" }: concatStringsSep "\n" (mapAttrsToList (keycomb: action: optionalString (action != null) "bindsym ${ - lib.optionalString (moduleName == "sway") "--to-code " + lib.optionalString (bindsymArgs != "") "${bindsymArgs} " }${keycomb} ${action}") keybindings); keycodebindingsStr = keycodebindings: @@ -31,7 +31,7 @@ rec { modeStr = name: keybindings: '' mode "${name}" { - ${keybindingsStr keybindings} + ${keybindingsStr { inherit keybindings; }} } ''; diff --git a/modules/services/window-managers/i3-sway/sway.nix b/modules/services/window-managers/i3-sway/sway.nix index 956560a93..91bfe0fad 100644 --- a/modules/services/window-managers/i3-sway/sway.nix +++ b/modules/services/window-managers/i3-sway/sway.nix @@ -139,6 +139,15 @@ let ''; }; + bindkeysToCode = mkOption { + type = types.bool; + default = false; + example = true; + description = '' + Whether to make use of in keybindings. + ''; + }; + input = mkOption { type = types.attrsOf (types.attrsOf types.str); default = { }; @@ -259,7 +268,11 @@ let client.placeholder ${colorSetStr colors.placeholder} client.background ${colors.background} - ${keybindingsStr keybindings} + ${keybindingsStr { + inherit keybindings; + bindsymArgs = + lib.optionalString (cfg.config.bindkeysToCode) "--to-code"; + }} ${keycodebindingsStr keycodebindings} ${concatStringsSep "\n" (mapAttrsToList inputStr input)} ${concatStringsSep "\n" (mapAttrsToList outputStr output)}