From 95201931f2e733705296d1d779e70793deaeb909 Mon Sep 17 00:00:00 2001
From: Kylie McClain <kylie@somas.is>
Date: Wed, 15 Mar 2023 14:22:12 -0400
Subject: [PATCH] qutebrowser: allow for specifying multiple commands in
 bindings (#3322)

This command adds the ability to specify lists of qutebrowser
commands as values for key bindings, which avoids the need for
concatenating commands with ` ;; `.
---
 modules/programs/qutebrowser.nix                   | 7 ++++++-
 tests/modules/programs/qutebrowser/keybindings.nix | 6 ++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/programs/qutebrowser.nix b/modules/programs/qutebrowser.nix
index 9220d496a..4c391f948 100644
--- a/modules/programs/qutebrowser.nix
+++ b/modules/programs/qutebrowser.nix
@@ -131,7 +131,7 @@ in {
     };
 
     keyBindings = mkOption {
-      type = types.attrsOf (types.attrsOf types.str);
+      type = with types; attrsOf (attrsOf (separatedString " ;; "));
       default = { };
       description = ''
         Key bindings mapping keys to commands in different modes. This setting
@@ -245,6 +245,11 @@ in {
             "<Ctrl-v>" = "spawn mpv {url}";
             ",p" = "spawn --userscript qute-pass";
             ",l" = '''config-cycle spellcheck.languages ["en-GB"] ["en-US"]''';
+            "<F1>" = mkMerge [
+              "config-cycle tabs.show never always"
+              "config-cycle statusbar.show in-mode always"
+              "config-cycle scrolling.bar never always"
+            ];
           };
           prompt = {
             "<Ctrl-y>" = "prompt-yes";
diff --git a/tests/modules/programs/qutebrowser/keybindings.nix b/tests/modules/programs/qutebrowser/keybindings.nix
index a719d9f76..258c57ad3 100644
--- a/tests/modules/programs/qutebrowser/keybindings.nix
+++ b/tests/modules/programs/qutebrowser/keybindings.nix
@@ -13,6 +13,11 @@ with lib;
         normal = {
           "<Ctrl-v>" = "spawn mpv {url}";
           ",l" = ''config-cycle spellcheck.languages ["en-GB"] ["en-US"]'';
+          "<F1>" = mkMerge [
+            "config-cycle tabs.show never always"
+            "config-cycle statusbar.show in-mode always"
+            "config-cycle scrolling.bar never always"
+          ];
         };
         prompt = { "<Ctrl-y>" = "prompt-yes"; };
       };
@@ -34,6 +39,7 @@ with lib;
             c.bindings.default = {}
             config.bind(",l", "config-cycle spellcheck.languages [\"en-GB\"] [\"en-US\"]", mode="normal")
             config.bind("<Ctrl-v>", "spawn mpv {url}", mode="normal")
+            config.bind("<F1>", "config-cycle tabs.show never always ;; config-cycle statusbar.show in-mode always ;; config-cycle scrolling.bar never always", mode="normal")
             config.bind("<Ctrl-y>", "prompt-yes", mode="prompt")''
         }
     '';