about summary refs log tree commit diff
path: root/modules/common/qutebrowser.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
committerAzat Bahawi <azat@bahawi.net>2024-03-31 21:29:27 +0300
commit9a5427e3a0c0ccf2a82dc503149a26b23fbd6004 (patch)
treef28beec29deeea36038615a8fb98a810891940b5 /modules/common/qutebrowser.nix
parent2024-03-19 (diff)
2024-03-31
Diffstat (limited to '')
-rw-r--r--modules/common/qutebrowser.nix179
1 files changed, 99 insertions, 80 deletions
diff --git a/modules/common/qutebrowser.nix b/modules/common/qutebrowser.nix
index a3b82d3..8fdcf48 100644
--- a/modules/common/qutebrowser.nix
+++ b/modules/common/qutebrowser.nix
@@ -4,9 +4,11 @@
   pkgs,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.qutebrowser;
-in {
+in
+{
   options.nixfiles.modules.qutebrowser.enable = mkEnableOption "Qutebrowser";
 
   config = mkIf cfg.enable {
@@ -20,9 +22,11 @@ in {
         enable = true;
 
         keyBindings.normal = mkIf mpv.enable {
-          "z" = let
-            mpv = getExe config.hm.programs.mpv.package;
-          in "hint links spawn --detach ${mpv} {hint-url}";
+          "z" =
+            let
+              mpv = getExe config.hm.programs.mpv.package;
+            in
+            "hint links spawn --detach ${mpv} {hint-url}";
         };
 
         searchEngines = rec {
@@ -147,7 +151,11 @@ in {
             shrink = true;
             timestamp_format = "%y-%m-%d";
             min_chars = 3;
-            open_categories = ["bookmarks" "quickmarks" "history"];
+            open_categories = [
+              "bookmarks"
+              "quickmarks"
+              "history"
+            ];
 
             scrollbar = {
               width = 0;
@@ -164,11 +172,7 @@ in {
           };
 
           editor.command = [
-            (
-              if alacritty.enable
-              then getExe pkgs.alacritty
-              else getExe pkgs.xterm
-            )
+            (if alacritty.enable then getExe pkgs.alacritty else getExe pkgs.xterm)
             "-e"
             (getExe' config.programs.vim.package "vim")
             "-f"
@@ -192,7 +196,11 @@ in {
             smooth = false;
           };
 
-          spellcheck.languages = ["en-US" "en-GB" "ru-RU"];
+          spellcheck.languages = [
+            "en-US"
+            "en-GB"
+            "ru-RU"
+          ];
 
           statusbar.position = "bottom";
 
@@ -233,7 +241,7 @@ in {
 
           url = rec {
             default_page = "about:blank";
-            start_pages = [default_page];
+            start_pages = [ default_page ];
           };
 
           window = {
@@ -248,76 +256,87 @@ in {
         };
 
         extraConfig =
-          (let
-            mkPaddingDictionary = {
-              name,
-              bottom,
-              left,
-              right,
-              top,
-            }: let
-              n = "c.${name}.padding";
-              b = "'bottom': ${toString bottom}";
-              l = "'left': ${toString left}";
-              r = "'right': ${toString right}";
-              t = "'top': ${toString top}";
-            in "${n} = {${b}, ${l}, ${r}, ${t}}";
-
-            final = map mkPaddingDictionary [
-              {
-                name = "hints";
-                bottom = 3;
-                left = 3;
-                right = 3;
-                top = 3;
-              }
-              {
-                name = "statusbar";
-                bottom = 1;
-                left = 0;
-                right = 3;
-                top = 1;
-              }
-              {
-                name = "tabs";
-                bottom = 1;
-                left = 6;
-                right = 6;
-                top = 1;
-              }
-            ];
-          in
-            concatLines final + "\n")
-          + (let
-            allowSetting = setting: url: "config.set('content.${setting}', True, '${url}')";
-
-            allowMediaCaptureSetting = url: [
-              (allowSetting "desktop_capture" url)
-              (allowSetting "media.audio_video_capture" url)
-            ];
-            allowedMediaCapture = flatten (map allowMediaCaptureSetting [
-              "https://discord.com"
-              "https://web.telegram.org"
-            ]);
-
-            allowNotificationsSetting = allowSetting "notifications.enabled";
-            allowedNotifications = map allowNotificationsSetting [
-              "https://discord.com"
-              "https://web.telegram.org"
-            ];
+          (
+            let
+              mkPaddingDictionary =
+                {
+                  name,
+                  bottom,
+                  left,
+                  right,
+                  top,
+                }:
+                let
+                  n = "c.${name}.padding";
+                  b = "'bottom': ${toString bottom}";
+                  l = "'left': ${toString left}";
+                  r = "'right': ${toString right}";
+                  t = "'top': ${toString top}";
+                in
+                "${n} = {${b}, ${l}, ${r}, ${t}}";
+
+              final = map mkPaddingDictionary [
+                {
+                  name = "hints";
+                  bottom = 3;
+                  left = 3;
+                  right = 3;
+                  top = 3;
+                }
+                {
+                  name = "statusbar";
+                  bottom = 1;
+                  left = 0;
+                  right = 3;
+                  top = 1;
+                }
+                {
+                  name = "tabs";
+                  bottom = 1;
+                  left = 6;
+                  right = 6;
+                  top = 1;
+                }
+              ];
+            in
+            concatLines final + "\n"
+          )
+          + (
+            let
+              allowSetting = setting: url: "config.set('content.${setting}', True, '${url}')";
+
+              allowMediaCaptureSetting = url: [
+                (allowSetting "desktop_capture" url)
+                (allowSetting "media.audio_video_capture" url)
+              ];
+              allowedMediaCapture = flatten (
+                map allowMediaCaptureSetting [
+                  "https://discord.com"
+                  "https://web.telegram.org"
+                ]
+              );
+
+              allowNotificationsSetting = allowSetting "notifications.enabled";
+              allowedNotifications = map allowNotificationsSetting [
+                "https://discord.com"
+                "https://web.telegram.org"
+              ];
 
-            final = allowedMediaCapture ++ allowedNotifications;
-          in
-            concatLines final + "\n");
+              final = allowedMediaCapture ++ allowedNotifications;
+            in
+            concatLines final + "\n"
+          );
       };
 
-      home.activation.installQutebrowserDictionaries = let
-        dictcli = "${pkgs.qutebrowser}/share/qutebrowser/scripts/dictcli.py";
-      in ''
-        if [[ ! -d "''${XDG_DATA_HOME:-$HOME/.local/share}/qutebrowser/qtwebengine_dictionaries" ]]; then
-            ${dictcli} install en-US en-GB ru-RU
-        fi
-      '';
+      home.activation.installQutebrowserDictionaries =
+        let
+          dictcli = "${pkgs.qutebrowser}/share/qutebrowser/scripts/dictcli.py";
+        in
+        ''
+          if [[ ! -d "''${XDG_DATA_HOME:-$HOME/.local/share}/qutebrowser/qtwebengine_dictionaries" ]]; then
+              ${dictcli} install en-US en-GB ru-RU
+          fi
+        '';
     };
   };
 }

Consider giving Nix/NixOS a try! <3