{
  config,
  pkgs,
  theme,
  ...
}: {
  programs.qutebrowser = {
    enable = true;

    searchEngines = {
      r = "https://doc.rust-lang.org/stable/std/?search={}";
      lib = "https://lib.rs/search?q={}";
      nip = "https://jisho.org/search/{}";
    };

    # TODO: Make this prettier overall
    settings =
      theme.apps.qutebrowser
      // {
        tabs = {
          indicator.width = 3;
        };

        # TODO: The terminal shouldn't be hardcoded
        editor.command = ["alacritty" "-c" "hx" "{file}"];

        # TODO: Take the value from theme
        fonts = {
          # default_family = "Cozette";
          # default_size = "13px";
          default_family = "Iosevka";
          default_size = "13px";
        };

        content = {
          canvas_reading = true;
          blocking.method = "both";
          blocking.whitelist = ["*.amplitude.com" "amplitude.com"];
        };
      };
    # Workaround because the nix module doesn't properly handle options that expect a dict
    extraConfig = ''
      c.tabs.padding = { 'top': 5, 'bottom': 5, 'right': 10, 'left': 10 }
      c.statusbar.padding = { 'top': 5, 'bottom': 5, 'right': 10, 'left': 10 }
    '';

    keyBindings = {
      passthrough = {
        "<Ctrl-Escape>" = "mode-leave";
      };
    };
  };

  xdg.mimeApps = {
    enable = pkgs.stdenv.isLinux;
    defaultApplications = {
      "x-scheme-handler/http" = "org.qutebrowser.qutebrowser.desktop";
      "x-scheme-handler/https" = "org.qutebrowser.qutebrowser.desktop";
      "x-scheme-handler/chrome" = "org.qutebrowser.qutebrowser.desktop";
      "text/html" = "org.qutebrowser.qutebrowser.desktop";
      "application/x-extension-htm" = "org.qutebrowser.qutebrowser.desktop";
      "application/x-extension-html" = "org.qutebrowser.qutebrowser.desktop";
      "application/x-extension-shtml" = "org.qutebrowser.qutebrowser.desktop";
      "application/xhtml+xml" = "org.qutebrowser.qutebrowser.desktop";
      "application/x-extension-xhtml" = "org.qutebrowser.qutebrowser.desktop";
      "application/x-extension-xht" = "org.qutebrowser.qutebrowser.desktop";
      "application/pdf" = "org.qutebrowser.qutebrowser.desktop";
    };
  };
}