working on yazi as file picker

This commit is contained in:
Matt Nish-Lapidus 2025-04-21 12:39:28 -04:00
parent 0192c8ed42
commit c62dd7b8a4
6 changed files with 58 additions and 9 deletions

View file

@ -28,11 +28,9 @@
rpi-imager
freecad
flatpak
gst_all_1.gstreamer
prusa-slicer
via
vial
scribus
pdfarranger
tdf
pdfchain
@ -44,6 +42,9 @@
soundconverter
wmctrl
scribus
gimp3
# godot_4
# gdtoolkit_4
@ -96,7 +97,6 @@
krita-plugin-gmic
rawtherapee
inkscape
gimp
# kicad
turbocase
openscad-unstable

View file

@ -0,0 +1,6 @@
### $XDG_CONFIG_HOME/xdg-desktop-portal-termfilechooser/config ###
[filechooser]
cmd=yazi-wrapper.sh
default_dir=$HOME
env=TERMCMD= wezlauncher

View file

@ -0,0 +1,40 @@
#!/bin/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 -ex
PATH="/usr/bin:/bin"
multiple="$1"
directory="$2"
save="$3"
path="$4"
out="$5"
cmd="yazi"
termcmd="${TERMCMD:-wezlauncher ''}"
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" "$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 spaces
command="$command \"$escaped\""
done
sh -c "$command"

View file

@ -198,4 +198,6 @@
xdg.configFile."yazi/theme.toml".source = ./yazi/theme.toml;
xdg.configFile."yazi/flavors".source = ./yazi/flavors;
xdg.configFile."xdg-desktop-portal-termfilechooser/config".source = ./file-chooser/config;
home.file.".local/bin/yazi-wrapper.sh".source = ./file-chooser/yazi-wrapper.sh;
}