dragon
dragon copied to clipboard
Can't drag from mtp mountpoint
When dragging from a gvfs-mtp mountpoint, dragon's behavior is different from thunar.
Thunar produce
file:///run/user/1000/gvfs/mtp:host=Android_OnePlus_a7de565f
Dragon produce
mtp:host=Android_OnePlus_a7de565f
Which can not be processed by chromium, so does all files in such mtp mountpoint.
g_file_get_uri
will convert
/run/user/1000/gvfs/mtp:host=Android_OnePlus_a7de565f/...
to
mtp://Android_OnePlus_a7de565f/...
I can't find a perfect method to force the uri scheme to file
instead of mtp
. My current workaround is to use a wrapper to make a symlink to such files, which works well for chromium.
#!/usr/bin/env bash
exe=$(which -a $(basename $0) | grep -v $0 | head -1)
tmp=$(mktemp -d)
arg=("$@")
for ((i = 0; i < $#; ++i)); do
src=${arg[i]}
if [[ $src == *mtp:* ]]; then
src=${src##file://}
dst="$tmp/$src"
mkdir -p "$(dirname "$dst")"
ln -s "$src" "$dst"
arg[i]="$dst"
fi
done
$exe "${arg[@]}"