ctucx.git: nixfiles

ctucx' nixfiles

commit 8524d70018cd84b5d4eb226b7c11cdbfeba49b3b
parent 1ca4edb995269f4867a4bd9bad2d975b20a51fdb
Author: Katja (ctucx) <git@ctu.cx>
Date: Thu, 27 Feb 2025 11:22:24 +0100

configurations/linux/programs/firefox: add dbnav-handler for `vdv-pkpass.magicalcodewit.ch`
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/configurations/linux/programs/firefox.nix b/configurations/linux/programs/firefox.nix
@@ -41,6 +41,25 @@ in {
         enable          = true;
         mime.enable     = true;
 
+        desktopEntries.dbnav-handler = {
+          startupNotify = false;
+          noDisplay     = true;
+          type          = "Application";
+          name          = "VDV PKPass DB Navigator Hook";
+          mimeType      = [ "x-scheme-handler/dbnav" ];
+          settings.NoDisplay = "true";
+          exec          = "/bin/sh -c \"${pkgs.writeShellScript "db-hook" ''
+            #!/usr/bin/env bash
+
+            if [[ "$1" == "dbnav:"* ]]; then
+              url=$(echo -n $1 | base64)
+              xdg-open "https://vdv-pkpass.magicalcodewit.ch/account/db_login/callback?url=$url"
+            else
+              xdg-open "$1"
+            fi
+          ''} %u\"";
+        };
+
         #force hm to override existing mimeapps.list file
         configFile."mimeapps.list".force = true;