okay.
i THINK i have finally managed it to work without home-manager and whatever, but ONLY for firefox/librewolf… theres a few problems though - it doesnt look like it works for steam, messengers, and etc., - for 25.05 using flakes, that is. problem two is that those errors i mentioned earlier didnt really go away… anyway, here is what i have done:
this is for wezterm and yazi
configuration.nix
# ...
environment.variables = {
GTK_USE_PORTAL = "1"; # legacy
GDK_DEBUG = "portals"; # termfilechooser
};
xdg = {
mime.enable = true;
portal = {
enable = true;
# xdgOpenUsePortal = true; # bypass 'xdg-open' -- NIXOS_XDG_OPEN_USE_PORTAL
config = {
common.default = [ "*" ];
common."org.freedesktop.impl.portal.FileChooser" = [ "termfilechooser" ]; # IMPORTANT!
extraPortals = [
pkgs.xdg-desktop-portal-termfilechooser
];
};
};
# ...
xdgOpenUsePortal should be false because termfilechooser is just a backend and not a portal, and should only be used for saving / picking dialogues, etc… i mean, it broke steam for me, for example! …but maybe im just silly.
~/.config/xdg-desktop-portal-termfilechooser/config
[filechooser]
cmd=$HOME/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
default_dir=$HOME/Downloads
~/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
#!/bin/sh
set -ex
multiple="$1"
directory="$2"
save="$3"
path="$4"
out="$5"
cmd="yazi"
termcmd="${TERMCMD:-wezterm start --always-new-process}"
if [ "$save" = "1" ]; then
set -- --chooser-file="$out" "$path"
elif [ "$directory" = "1" ]; then
set -- --chooser-file="$out" --cwd-file="$out" "$path"
elif [ "$multiple" = "1" ]; then
set -- --chooser-file="$out" "$path"
else
set -- --chooser-file="$out" "$path"
fi
command="$termcmd $cmd"
for arg in "$@"; do
escaped=$(printf "%s" "$arg" | sed 's/"/\\"/g')
command="$command \"$escaped\""
done
sh -c "$command"
librewolf/firefox about:config
widget.use-xdg-desktop-portal.file-picker = 1
so… all that just for browser’s “save as” dialogue…
i probably broke something anyway…
is there a way to “enforce” it to apply to ALL applications? or at least specific apps? 