From f345fef5408861f4b92b1784de19cb5010b2dc7e Mon Sep 17 00:00:00 2001 From: kenji Date: Sun, 11 Jan 2026 11:33:08 -0600 Subject: [PATCH] feat(yazi): enable yazi as system-wide file chooser Configure xdg-desktop-portal-termfilechooser to use yazi (via ghostty) for file selection dialogs in portal-aware apps like Firefox. Includes a wrapper script and Hyprland window rules. --- apps/hyprland/hypr/rules.nix | 3 +++ apps/yazi/default.nix | 20 +++++++++++++++++++- modules/nixos/hyprland.nix | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/apps/hyprland/hypr/rules.nix b/apps/hyprland/hypr/rules.nix index b02cc05..9bb5448 100644 --- a/apps/hyprland/hypr/rules.nix +++ b/apps/hyprland/hypr/rules.nix @@ -4,6 +4,9 @@ ]; windowrulev2 = [ + "float, class:^(yazi-file-picker)$" + "size 60% 60%, class:^(yazi-file-picker)$" + "center, class:^(yazi-file-picker)$" ]; }; } diff --git a/apps/yazi/default.nix b/apps/yazi/default.nix index 5d8dd48..ca86cf2 100644 --- a/apps/yazi/default.nix +++ b/apps/yazi/default.nix @@ -1,4 +1,15 @@ -{pkgs, ...}: { +{ + pkgs, + myConfig, + ... +}: let + yazi-file-picker = pkgs.writeShellScriptBin "yazi-file-picker" '' + path="$1" + # multiple="$2" + # directory="$3" + ${pkgs.yazi}/bin/yazi --chooser-file="$path" + ''; +in { programs.yazi = { enable = true; enableFishIntegration = true; @@ -11,4 +22,11 @@ }; }; }; + + home.packages = [yazi-file-picker]; + + xdg.configFile."xdg-desktop-portal-termfilechooser/config".text = '' + [filechooser] + cmd=${pkgs.ghostty}/bin/ghostty --class=yazi-file-picker -e ${yazi-file-picker}/bin/yazi-file-picker + ''; } diff --git a/modules/nixos/hyprland.nix b/modules/nixos/hyprland.nix index f19a764..978795b 100644 --- a/modules/nixos/hyprland.nix +++ b/modules/nixos/hyprland.nix @@ -24,4 +24,18 @@ default = ["${myConfig.terminal.default}"]; }; }; + + xdg.portal = { + enable = true; + extraPortals = [ + pkgs.xdg-desktop-portal-termfilechooser + pkgs.xdg-desktop-portal-gtk + ]; + config = { + common = { + default = ["gtk"]; + "org.freedesktop.impl.portal.FileChooser" = ["termfilechooser"]; + }; + }; + }; } \ No newline at end of file