feat(hyprland): integrate yazi as global file picker via xdg-portal

This commit is contained in:
kenji
2026-01-11 10:44:25 -06:00
parent 78f6ede871
commit 63becaaa09
3 changed files with 61 additions and 1 deletions
+41 -1
View File
@@ -1,4 +1,35 @@
{pkgs, ...}: {
{
pkgs,
config,
...
}: let
yazi-picker = pkgs.writeShellScriptBin "yazi-picker" ''
path="$1"
[ -z "$path" ] && path="."
if [ "$2" = "true" ]; then
# Save file mode
# In save mode, we might want to just open the directory,
# but yazi --chooser-file works for picking a file to overwrite or a directory.
# For a "Save As" flow where you type a name, standard yazi chooser might be limited
# without custom lua, but selecting a directory works.
# For now, treat same as open.
:
fi
out="$HOME/.cache/yazi-chooser"
rm -f "$out"
# We need to block until ghostty closes, or use --wait if available/default behavior.
# Ghostty -e does not automatically detach, so it should block.
${pkgs.ghostty}/bin/ghostty --class="yazi-picker" --title="File Picker" -e ${pkgs.yazi}/bin/yazi "$path" --chooser-file="$out"
if [ -f "$out" ]; then
cat "$out"
rm "$out"
fi
'';
in {
programs.yazi = {
enable = true;
enableFishIntegration = true;
@@ -11,4 +42,13 @@
};
};
};
home.packages = [
yazi-picker
];
xdg.configFile."xdg-desktop-portal-termfilechooser/config".text = ''
[filechooser]
cmd=${yazi-picker}/bin/yazi-picker
'';
}