mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update 2025-08-07
This commit is contained in:
59
config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
Executable file
59
config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/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="${TERMCMD:-kitty --title 'termfilechooser'}"
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user