dragon icon indicating copy to clipboard operation
dragon copied to clipboard

Can't drag from mtp mountpoint

Open tkkcc opened this issue 3 years ago • 1 comments

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.

tkkcc avatar Mar 28 '21 07:03 tkkcc

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[@]}"

tkkcc avatar Mar 30 '21 06:03 tkkcc