diff --git a/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh b/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh new file mode 100755 index 0000000..30d8077 --- /dev/null +++ b/.config/xdg-desktop-portal-termfilechooser/yazi-wrapper.sh @@ -0,0 +1,39 @@ +#!/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 -ex + +multiple="$1" +directory="$2" +save="$3" +path="$4" +out="$5" + +cmd="yazi" +termcmd='ghostty --working-directory="~/" --title="Yazi-STANDALONE" -e' + +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" diff --git a/.config/yadm/bootstrap.v2/applications/30-Yazi.sh b/.config/yadm/bootstrap.v2/applications/30-Yazi.sh index 7e49529..e4fd17e 100755 --- a/.config/yadm/bootstrap.v2/applications/30-Yazi.sh +++ b/.config/yadm/bootstrap.v2/applications/30-Yazi.sh @@ -1,6 +1,13 @@ #!/bin/env sh addApplications yazi p7zip jq poppler fd ripgrep fzf zoxide imagemagick fuse-archive zip \ - blobdrop-git ouch + blobdrop-git ouch xdg-desktop-portal-termfilechooser-hunkyburrito-git -addActions "ya pack -i" +setupYazi() { + ya pack -i + + systemctl --user restart xdg-desktop-portal-termfilechooser + systemctl --user restart xdg-desktop-portal +} + +addActions setupYazi diff --git a/.gitignore b/.gitignore index 0ec56c5..3148608 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ !/.config/wal/ !/.config/zathura/ !/.config/terminal/ +!/.config/xdg-desktop-portal-termfilechooser/ !/.ssh/ /.ssh/*