From 28f94e89d510b948c74ff5f38305a7f36f103d18 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Thu, 30 Nov 2023 10:22:58 +0100 Subject: [PATCH] pinwheel: Add `ff-alex` and use it as the default browser --- hosts/pinwheel/modules/emacs/config.org | 4 ++ hosts/pinwheel/modules/firefox/default.nix | 43 +++++++++++++++++++++- hosts/pinwheel/modules/zsh/default.nix | 4 -- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/hosts/pinwheel/modules/emacs/config.org b/hosts/pinwheel/modules/emacs/config.org index d2ddcd1..5f51024 100644 --- a/hosts/pinwheel/modules/emacs/config.org +++ b/hosts/pinwheel/modules/emacs/config.org @@ -402,6 +402,10 @@ Setup prefix for keybindings. "ts" '(hydra-text-scale/body :which-key "scale text")) #+END_SRC +* Browser +#+BEGIN_SRC emacs-lisp + (setq browse-url-firefox-program "ff-alex") +#+END_SRC * Evil #+BEGIN_SRC emacs-lisp (use-package evil diff --git a/hosts/pinwheel/modules/firefox/default.nix b/hosts/pinwheel/modules/firefox/default.nix index d4f8b4e..8d3e027 100644 --- a/hosts/pinwheel/modules/firefox/default.nix +++ b/hosts/pinwheel/modules/firefox/default.nix @@ -29,7 +29,14 @@ let ff = pkgs.writeShellApplication { name = "ff"; text = '' - ${wrapped}/bin/firefox -p + ${wrapped}/bin/firefox --ProfileManager + ''; + }; + + ff-alex = pkgs.writeShellApplication { + name = "ff-alex"; + text = '' + ${wrapped}/bin/firefox -P alex --new-window "$@" ''; }; @@ -49,6 +56,7 @@ in alex = { id = 0; name = "alex"; + isDefault = true; settings = sharedSettings // {}; }; @@ -70,6 +78,39 @@ in }; }; + xdg = { + # /etc/profiles/per-user/alex/share/applications + desktopEntries = { + ff-alex = { + name = "ff-alex"; + exec = "${ff-alex}/bin/ff-alex %U"; + terminal = false; + }; + }; + + mimeApps = { + enable = true; + + defaultApplications = { + "text/html" = "ff-alex.desktop"; + "x-scheme-handler/http" = "ff-alex.desktop"; + "x-scheme-handler/https" = "ff-alex.desktop"; + "application/x-exension-htm" = "ff-alex.desktop"; + "application/x-exension-html" = "ff-alex.desktop"; + "application/x-exension-shtml" = "ff-alex.desktop"; + "application/xhtml+xml" = "ff-alex.desktop"; + "application/x-exension-xhtml" = "ff-alex.desktop"; + "application/x-exension-xht" = "ff-alex.desktop"; + }; + }; + + # https://github.com/nix-community/home-manager/issues/1213 + configFile."mimeapps.list".force = true; + }; + + home.packages = [ ff ]; }; + + environment.variables.BROWSER = "${ff-alex}/bin/ff-alex $@"; } diff --git a/hosts/pinwheel/modules/zsh/default.nix b/hosts/pinwheel/modules/zsh/default.nix index 9e91717..bfbb8d0 100644 --- a/hosts/pinwheel/modules/zsh/default.nix +++ b/hosts/pinwheel/modules/zsh/default.nix @@ -49,10 +49,6 @@ in } ]; - envExtra = lib.strings.concatStringsSep "\n" [ - "BROWSER=firefox" - ]; - initExtra = lib.strings.concatStringsSep "\n" [ "export KEYTIMEOUT=1" "bindkey -v '^?' backward-delete-char"