Skip to content

Instantly share code, notes, and snippets.

@Misko-2083
Created May 7, 2022 14:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Misko-2083/04a7be791e0db74ca372036e9fdb5c65 to your computer and use it in GitHub Desktop.
Save Misko-2083/04a7be791e0db74ca372036e9fdb5c65 to your computer and use it in GitHub Desktop.
#!/bin/bash
#install gridsite-clients for urlencode
# also requires gio
cd $HOME
export LASTDIR="$(mktemp --tmpdir yadlastfm.XXXXXXXX)"
export TEMP="$(mktemp --dry-run --tmpdir yadfm.XXXXXXXX)"
mkfifo -m 0644 "${TEMP}"
exec 3<> "${TEMP}"
trap "rm -f ${TEMP} ${LASTDIR}" 0 1 2 15
list_fd () {
: ${F:=$@}
if [[ -d "${F}" ]]; then
echo -e "\f" >"${TEMP}"
echo ".." >"${TEMP}"
case "${F}" in
'recent:///') cd "$HOME" ;;
'trash:///') cd "$HOME" ;;
"..")
F="$(<${LASTDIR})"
if [[ ! -d "${F}" ]]
then
F="${F%/${F##*/}*}"
fi
cd "${F}"
echo "${F%/${F##*/}*}" >"$LASTDIR" ;;
*)
cd "${F}"
echo "${F%/${F##*/}*}" >"$LASTDIR";;
esac
gio list -u -h -n -- "$F" | awk -F'file://' '{print $2}' | xargs -0 urlencode -d >"${TEMP}"
else
gio open -- "${F}"
fi
}
export -f list_fd
KEY="$(($RANDOM * $$ / 100))"
{ echo ${HOME:=/home}; yad --plug=$KEY --tabnum=1 --places; } \
| while read -r FOLDER; do
echo "${FOLDER}" >"$LASTDIR"
echo -e "\f"
echo ".."
case "$FOLDER" in
"recent:///") gio list -u -h -n -d -a standard::target-uri recent:/// | awk -F'file://' '{print $2}' | xargs -0 urlencode -d ;;
"trash:///") gio list trash:/// ;;
*) gio list -u -h -n -- "$FOLDER" | awk -F'file://' '{print $2}' | xargs -0 urlencode -d ;;
esac
done >&3 &
yad --plug=$KEY --tabnum=2 --list --column=Name --listen --no-markup \
--dclick-action='bash -c "list_fd %s"' <&3 &
yad --paned --key=$KEY --orient=horizontal --width=800 --height=500
exec 3>&-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment