feat(hyprland): integrate yazi as global file picker via xdg-portal
This commit is contained in:
+41
-1
@@ -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
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user