(bruh discourse deleted my concept message so im writing this anew…)
alright! time to test termfilechooser AND termfilepickers for the 9000th time! (cos it didnt really work last time for me…)
configuration.nix
xdg.portal.extraPortals = [
pkgs.xdg-desktop-portal-termfilechooser
];
expectation: should work out of the box! 
reality: the portal service doesnt even start! 
EDIT: not until i added this:
xdg.portal.config.common."org.freedesktop.impl.portal.FileChooser" = [ "termfilechooser" ];
anyway, to make it work, i also had to MANUALLY create configs:
$HOME/.config/xdg-desktop-portal-termfilechooser/config
[filechooser]
cmd=yazi-wrapper.sh
default_dir=$HOME
; Uncomment to skip creating destination save files with instructions in them
; create_help_file=0
; Mode must be one of 'suggested', 'default', or 'last'.
open_mode=suggested
save_mode=last
i removed the env=TERMCMD=foot because see below:
$HOME/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
#!/usr/bin/env sh
# This wrapper script is invoked by xdg-desktop-portal-termfilechooser.
#
# For more information about input/output arguments read `xdg-desktop-portal-termfilechooser(5)`
set -e
if [ "$6" -ge 4 ]; then
set -x
fi
multiple="$1"
directory="$2"
save="$3"
path="$4"
out="$5"
cmd="yazi"
termcmd="wezterm start --always-new-process"
if [ "$save" = "1" ]; then
# save a file
set -- --chooser-file="$out" "$path"
elif [ "$directory" = "1" ]; then
# upload files from a directory
set -- --chooser-file="$out" --cwd-file="$out"".1" "$path"
elif [ "$multiple" = "1" ]; then
# upload multiple files
set -- --chooser-file="$out" "$path"
else
# upload only 1 file
set -- --chooser-file="$out" "$path"
fi
command="$termcmd $cmd"
for arg in "$@"; do
# escape double quotes
escaped=$(printf "%s" "$arg" | sed 's/"/\\"/g')
# escape special
case "$termcmd" in
*"ghostty"*)
command="$command \"\\\"$escaped\\\"\"";;
*)
command="$command \"$escaped\"";;
esac
done
sh -c "$command"
if [ "$directory" = "1" ]; then
if [ ! -s "$out" ] && [ -s "$out"".1" ]; then
cat "$out"".1" > "$out"
rm "$out"".1"
else
rm "$out"".1"
fi
fi
termcmd with ${TERMCMD} was spitting errors, saying it is “deprecated” on rebulid (i am using nix-maid). anyway, i am also using pkgs.wezterm! i dont care about the terminal title, but one could use wezterm cli set-window-title TITLE, just remember the --always-new-process!
make it executable!
chmod +x yazi-wrapper.sh
finally, remember the about:config (firefox/librewolf) property:
widget.use-xdg-desktop-portal.file-picker = 1 # https://searchfox.org/firefox-main/source/modules/libpref/init/StaticPrefList.yaml#18949
and NOW it WORKS! but not everywhere… some apps use their own portals? there might be a way to change this, but i either forgor the variable, or it’s way too jank and probably not worth it.
but is it scary to use it! IT IS! for instance, when you download something and pick the location, you MANUALLY pick a name for the file you want to download. no file extension provided, you do it yourself, so make sure you know what kind of… file extension you are downloading - though, you can use another compatible extension, for example, if its a .png, but you create a file called haha.jpeg - it will still work.
anyway, the way it does things:
- A) pick the example file which automatically generates with the name and extension which would’ve been used were you to use a GUI, like via browser or
- B) YOU manually create a file with the extension that you type in (via your TUI file manager or beforehand somewhere else) or
- C) you OVERWRITE an existing file, completely, with the new downloaded contents.
which sounds a bit scary, especially when working with multiple files! ESPECIALLY because TUI file managers can select DIRECTORIES. what if you overwrite A DIRECTORY???!!! but still, if one never wanna leave their trusty terminal, this is good, i think? 
sucks that it doesnt create the config files (and wrappers!) itself though… that’s a few points taken away! 
…moving on to termfilepickers! (plural?)
it is a flake btw, and it has a module (options for configuration.nix), which is pretty good (ive talked about it a few posts above, btw and sry, i was a bit dumb, but im learning things!)
configuration.nix
services.xdg-desktop-portal-termfilepickers = { # flake!
enable = true; # https://github.com/Guekka/xdg-desktop-portal-termfilepickers
package = inputs.xdg-desktop-portal-termfilepickers.packages.${pkgs.system}.default;
# desktopEnvironments = [ "common" ]; # "*"
config = {
# open_file_script_path = "$HOME/.local/share/wrappers/yazi-open-file.nu";
# save_file_script_path = "$HOME/.local/share/wrappers/yazi-save-file.nu"; # singular
# save_files_script_path = "$HOME/.local/share/wrappers/yazi-save-file.nu"; # multiple
terminal_command = [ (lib.getExe pkgs.wezterm) "start" "--always-new-process" ];
};
};
EDIT: uhm. apparently the paths are not of type absolute path? hmm…
i also (just in case) put the (only!) two nushell wrappers in $HOME/.config/xdg-desktop-portal-termfilepickers/ and made them executable, ofc
rebuilt, rebooted, and the xdg-desktop-portal-termfilepickers.service is up and running! doing good so far… BUT SUDDENLY!
testing zenity --file-selection
Unable to spawn yazi because:
No viable candidates found in PATH "/nix/store/8ksax0a2mxglr5hlkj2dzl556jx7xqn5-coreutils-9.7/bin:/nix/store/l964krgbp613d5jxga2vy5qdssj7zfzj-findutils-4.10.0/bin:/nix/store/vlckk0vnmawq9wwh7ndkrwxlpv4h29yh-gnugrep-3.12/bin:/nix/store/pmhkmqy0vxk47r6ndh0azybhf6gs6k25-gnused-4.9/bin:/nix/store/acjdidq41qig9khxcm7gx1d7brzjs249-systemd-257.8/bin:/nix/store/8ksax0a2mxglr5hlkj2dzl556jx7xqn5-coreutils-9.7/sbin:/nix/store/l964krgbp613d5jxga2vy5qdssj7zfzj-findutils-4.10.0/sbin:/nix/store/vlckk0vnmawq9wwh7ndkrwxlpv4h29yh-gnugrep-3.12/sbin:/nix/store/pmhkmqy0vxk47r6ndh0azybhf6gs6k25-gnused-4.9/sbin:/nix/store/acjdidq41qig9khxcm7gx1d7brzjs249-systemd-257.8/sbin"
⚠️ Process "yazi --chooser-file /tmp/.tmpEW6gQk" in domain "local" didn't exit cleanly
Exited with code 1.
This message is shown because exit_behavior="CloseOnCleanExit"
testing downloading a random image from librewolf browser:
Unable to spawn yazi because:
No viable candidates found in PATH "/nix/store/8ksax0a2mxglr5hlkj2dzl556jx7xqn5-coreutils-9.7/bin:/nix/store/l964krgbp613d5jxga2vy5qdssj7zfzj-findutils-4.10.0/bin:/nix/store/vlckk0vnmawq9wwh7ndkrwxlpv4h29yh-gnugrep-3.12/bin:/nix/store/pmhkmqy0vxk47r6ndh0azybhf6gs6k25-gnused-4.9/bin:/nix/store/acjdidq41qig9khxcm7gx1d7brzjs249-systemd-257.8/bin:/nix/store/8ksax0a2mxglr5hlkj2dzl556jx7xqn5-coreutils-9.7/sbin:/nix/store/l964krgbp613d5jxga2vy5qdssj7zfzj-findutils-4.10.0/sbin:/nix/store/vlckk0vnmawq9wwh7ndkrwxlpv4h29yh-gnugrep-3.12/sbin:/nix/store/pmhkmqy0vxk47r6ndh0azybhf6gs6k25-gnused-4.9/sbin:/nix/store/acjdidq41qig9khxcm7gx1d7brzjs249-systemd-257.8/sbin"
⚠️ Process "yazi --chooser-file /tmp/.tmpnfolUw /home/deck/Downloads/test.png" in domain "local" didn't exit cleanly
Exited with code 1.
This message is shown because exit_behavior="CloseOnCleanExit"
yeah. dead end. SPECULATION TIME:
- nushell moment! maybe this helps (the part where they talk about the $PATH?)
- i am using
(lib.hiPrio pkgs.uutils-coreutils-noprefix) btw, does termfilepickers only works with GNU pkgs.coreutils/pkgs.findutils? surely not, right? im too lazy to check!
well… it kinda works but… only with pkgs.nushell (by default). so that’s gonna be… tsk… sigh… a few points taken away. 
dont get me wrong, i LOVE nushell, but i am right now in a scenario where i dont have one set up, at all.
or am i dumb again? idk. sorry, i tried making it work… 