diff --git a/home/programs/gui/helium/default.nix b/home/programs/gui/helium/default.nix index b8a094f2..c1c92377 100644 --- a/home/programs/gui/helium/default.nix +++ b/home/programs/gui/helium/default.nix @@ -91,6 +91,7 @@ nativeBuildInputs = [pkgs.makeWrapper]; postBuild = '' wrapProgram $out/bin/helium \ + --set-default GTK_USE_PORTAL 1 \ --run ${lib.escapeShellArg (toString patchScript)} ''; }; diff --git a/home/system/termfilechooser/default.nix b/home/system/termfilechooser/default.nix new file mode 100644 index 00000000..a85ab280 --- /dev/null +++ b/home/system/termfilechooser/default.nix @@ -0,0 +1,24 @@ +# Use yazi as the file picker for portal dialogs (browser "select file(s)" and +# "save download to..."). The backend is xdg-desktop-portal-termfilechooser, +# enabled system-wide in nixos/utils.nix (extraPortals + FileChooser routing). +{ + config, + pkgs, + ... +}: let + wrapper = "${pkgs.xdg-desktop-portal-termfilechooser}/share/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh"; + # ghostty must run in the foreground instead of handing off to the + # single-instance daemon, otherwise the wrapper returns before you've picked + # anything and the portal reads an empty selection. + termcmd = "ghostty --gtk-single-instance=false --title=termfilechooser -e"; +in { + xdg.configFile."xdg-desktop-portal-termfilechooser/config".text = '' + [filechooser] + cmd=${wrapper} + default_dir=$HOME + open_mode=suggested + save_mode=suggested + env=TERMCMD=${termcmd} + PATH=${config.home.profileDirectory}/bin:/run/current-system/sw/bin:/run/wrappers/bin + ''; +} diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index a6c225a5..6960493d 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -38,6 +38,7 @@ ../../home/system/swaync ../../home/system/tofi ../../home/system/mime + ../../home/system/termfilechooser ../../home/system/udiskie ../../home/system/clipboard ../../home/system/hypridle diff --git a/hosts/work/home.nix b/hosts/work/home.nix index a0b9dcfd..430940b5 100644 --- a/hosts/work/home.nix +++ b/hosts/work/home.nix @@ -35,6 +35,7 @@ ../../home/system/swaync ../../home/system/tofi ../../home/system/mime + ../../home/system/termfilechooser ../../home/system/udiskie ../../home/system/clipboard ../../home/system/hypridle diff --git a/nixos/utils.nix b/nixos/utils.nix index 6e62989b..cec705c1 100644 --- a/nixos/utils.nix +++ b/nixos/utils.nix @@ -119,13 +119,20 @@ in { xdgOpenUsePortal = true; config = { common.default = ["gtk"]; - hyprland.default = [ - "gtk" - "hyprland" - ]; + hyprland = { + default = [ + "gtk" + "hyprland" + ]; + # Pick files / choose download paths with yazi instead of the GTK dialog + "org.freedesktop.portal.FileChooser" = ["termfilechooser"]; + }; }; - extraPortals = [pkgs.xdg-desktop-portal-gtk]; + extraPortals = [ + pkgs.xdg-desktop-portal-gtk + pkgs.xdg-desktop-portal-termfilechooser + ]; }; security.rtkit.enable = true; diff --git a/todo b/todo index 4d496c53..1a0d3440 100644 --- a/todo +++ b/todo @@ -2,3 +2,4 @@ - Check claude: Sécu, mots en français, faute, ... - LOW BATTERY OSD - a jour ./docs/NEOVIM.md +yazi as a file chooser