From 75437210209fdad871da69924e6e35db56d26638 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 28 Sep 2025 15:14:20 -0400 Subject: [PATCH] launch helix for editing desktop text files --- .../modules/nmasur/presets/programs/helix.nix | 21 +++++++++++++++++++ .../nmasur/presets/programs/neovim.nix | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/platforms/home-manager/modules/nmasur/presets/programs/helix.nix b/platforms/home-manager/modules/nmasur/presets/programs/helix.nix index 3f73700..2c7e963 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/helix.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/helix.nix @@ -454,6 +454,27 @@ in }; + # Create a desktop option for launching Helix from a file manager + # (Requires launching the terminal and then executing Helix) + xdg.desktopEntries.helix = + lib.mkIf (pkgs.stdenv.isLinux && config.nmasur.presets.services.i3.enable) + { + name = "Helix wrapper"; + exec = ''sh -c "${lib.getExe config.nmasur.presets.services.i3.terminal} --command='hx \$1'" _ %F ''; # TODO: change to work for any terminal + mimeType = [ + "text/plain" + "text/markdown" + ]; + }; + xdg.mimeApps.defaultApplications = { + "text/plain" = lib.mkBefore [ "Helix.desktop" ]; + "text/markdown" = lib.mkBefore [ "Helix.desktop" ]; + }; + + home.packages = [ + (pkgs.writers.writeDashBin "xterm" ''${lib.getExe config.nmasur.presets.services.i3.terminal} +new-window --command"$@" '') + ]; + }; } diff --git a/platforms/home-manager/modules/nmasur/presets/programs/neovim.nix b/platforms/home-manager/modules/nmasur/presets/programs/neovim.nix index 2807e4e..924dfcd 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/neovim.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/neovim.nix @@ -66,7 +66,7 @@ in lib.mkIf (pkgs.stdenv.isLinux && config.nmasur.presets.services.i3.enable) { name = "Neovim wrapper"; - exec = "${lib.getExe config.nmasur.presets.services.i3.terminal} nvim %F"; # TODO: change to generic + exec = ''${lib.getExe config.nmasur.presets.services.i3.terminal} --command="nvim %F"''; # TODO: change to generic mimeType = [ "text/plain" "text/markdown"