From 95930bc83e9262311d01bdfee1757a2c1d91d6a0 Mon Sep 17 00:00:00 2001 From: Fabian Montero Date: Fri, 7 Feb 2025 12:36:22 -0600 Subject: [PATCH] improve firefox module --- home/modules/firefox.nix | 47 +++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 15 deletions(-) diff --git a/home/modules/firefox.nix b/home/modules/firefox.nix index ec2c867..b2c7f10 100644 --- a/home/modules/firefox.nix +++ b/home/modules/firefox.nix @@ -14,27 +14,44 @@ in { type = types.nullOr types.str; default = null; description = '' - Workspace in which Firefox should open. If not set, Firefox will not open at startup. + i3 Workspace in which Firefox should open. If not set, Firefox will not open at startup + ''; + }; + + makeDefaultBrowser = mkOption { + type = types.bool; + default = true; + description = '' + Take a guess ''; }; }; - config = mkIf cfg.enable { - programs.firefox.enable = true; + config = mkIf cfg.enable (mkMerge [ + { + programs.firefox.enable = true; - xdg = { - mimeApps = { - enable = true; - defaultApplications = { - "text/uri-list" = with pkgs; ["firefox"]; - "x-scheme-handler/http" = with pkgs; ["firefox"]; - "x-scheme-handler/https" = with pkgs; ["firefox"]; + xsession.windowManager.i3.config.startup = optional (cfg.workspace != null) { + command = "${lib.getExe pkgs.i3-gaps} 'workspace ${cfg.workspace}; exec ${lib.getExe pkgs.firefox}'"; + }; + } + + (mkIf cfg.makeDefaultBrowser { + xdg = { + mimeApps = { + enable = true; + defaultApplications = { + "text/html" = ["firefox"]; + "text/uri-list" = ["firefox"]; + "x-scheme-handler/http" = ["firefox"]; + "x-scheme-handler/https" = ["firefox"]; + "x-scheme-handler/about" = ["firefox"]; + "x-scheme-handler/unknown" = ["firefox"]; + }; }; }; - }; - xsession.windowManager.i3.config.startup = optional (cfg.workspace != null) { - command = "${lib.getExe pkgs.i3-gaps} 'workspace ${cfg.workspace}; exec ${lib.getExe pkgs.firefox}'"; - }; - }; + home.sessionVariables.DEFAULT_BROWSER = "${lib.getExe pkgs.firefox}"; + }) + ]); }