feat(hyprland): integrate yazi as global file picker via xdg-portal
This commit is contained in:
@@ -4,6 +4,14 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
windowrulev2 = [
|
windowrulev2 = [
|
||||||
|
"suppressevent maximize, class:.*"
|
||||||
|
|
||||||
|
# --- YAZI FILE PICKER ---
|
||||||
|
"float, class:^(yazi-picker)$"
|
||||||
|
"center, class:^(yazi-picker)$"
|
||||||
|
"size 60% 60%, class:^(yazi-picker)$"
|
||||||
|
"dimaround, class:^(yazi-picker)$"
|
||||||
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+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 = {
|
programs.yazi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableFishIntegration = 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
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,4 +24,16 @@
|
|||||||
default = ["${myConfig.terminal.default}"];
|
default = ["${myConfig.terminal.default}"];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xdg.portal = {
|
||||||
|
enable = true;
|
||||||
|
extraPortals = [
|
||||||
|
pkgs.xdg-desktop-portal-hyprland
|
||||||
|
pkgs.xdg-desktop-portal-termfilechooser
|
||||||
|
];
|
||||||
|
config.common = {
|
||||||
|
default = ["hyprland"];
|
||||||
|
"org.freedesktop.impl.portal.FileChooser" = "termfilechooser";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user