about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2023-06-30T15·24+0300
committerclbot <clbot@tvl.fyi>2023-07-01T10·21+0000
commit0a6b82070d6fd19739184c55ba057bf378ef6b6f (patch)
tree2e7d044c9e62d25baea2acb5d4594863433c577d
parentc9272e0651047c7fb8fe5542fd3d999384b3dfa5 (diff)
feat(tazjin/home): add URL handler for sending `tg://` to telega r/6377
Change-Id: I72b19ee758165f92c1a202781beec4350c728a47
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8911
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: tazjin <tazjin@tvl.su>
-rw-r--r--users/tazjin/home/shared.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/users/tazjin/home/shared.nix b/users/tazjin/home/shared.nix
index 2baf4dade36e..df81932ccd63 100644
--- a/users/tazjin/home/shared.nix
+++ b/users/tazjin/home/shared.nix
@@ -3,6 +3,14 @@
 { depot, pkgs, ... }: # readTree
 { config, lib, ... }: # home-manager
 
+
+let
+  # URL handler to open `tg://` URLs in telega.el
+  telega-launcher = pkgs.writeShellScriptBin "telega-launcher" ''
+    echo "Opening ''${1} in telega.el ..."
+    ${pkgs.emacs-unstable}/bin/emacsclient -e "(telega-browse-url \"''${1}\")"
+  '';
+in
 {
   home.activation.screenshots = lib.hm.dag.entryAnywhere ''
     $DRY_RUN_CMD mkdir -p $HOME/screenshots
@@ -32,6 +40,27 @@
     lockCmd = "${depot.users.tazjin.screenLock}/bin/tazjin-screen-lock";
   };
 
+  home.packages = [ telega-launcher ];
+
+  xdg.desktopEntries.telega-launcher = {
+    name = "Telega Launcher";
+    exec = "${telega-launcher}/bin/telega-launcher";
+    terminal = false;
+    mimeType = [ "x-scheme-handler/tg" ];
+  };
+
+  xdg.mimeApps = {
+    enable = true;
+    defaultApplications = {
+      "x-scheme-handler/tg" = [ "telega-launcher.desktop" ];
+      "text/html" = [ "chromium-browser.desktop" ];
+      "x-scheme-handler/http" = [ "chromium-browser.desktop" ];
+      "x-scheme-handler/https" = [ "chromium-browser.desktop" ];
+      "x-scheme-handler/about" = [ "chromium-browser.desktop" ];
+      "x-scheme-handler/unknown" = [ "chromium-browser.desktop" ];
+    };
+  };
+
   services.picom = {
     enable = true;
     vSync = true;