Open jtrv opened 3 years ago
Just got back around to this.
You can use mwh/dragon to open a file with joshuto via mimetype.toml
image_default = [
{ command = "dragon", fork = true, silent = true }
]
Simple script with support dragging from or to the file manager (requires perl). It doesn't have much testing
#!/usr/bin/bash
while getopts ":e:t" option; do
case $option in
e)
# The maximum amount of results to show with preview
# If this exact amount of files is selected, --all-compact is used
MAX_RESULTS=7
if [ $# -gt "$MAX_RESULTS" ]; then
dragon-drop --and-exit --all-compact "${@:2}"
else
dragon-drop --and-exit "${@:2}"
fi
;;
t)
source="$(dragon-drop --and-exit --target)"
case "$source" in
file*)
file="$(echo "$source" | perl -MURI -MURI::Escape -lne \
'print uri_unescape(URI->new($_)->path)')"
if [ -f "$file" ];then
cp "$file" "$(pwd)/"
else
notify-send "❌" "There was a problem getting the file"
fi
;;
https*)
wget -q "$source"
dl_status=$?
if [ "$dl_status" -eq 0 ]; then
notify-send "✅" "File downloaded successfully"
else
notify-send "❌" "There was a problem getting the file"
fi
;;
\?)
notify-send "❌" "Whatever you dragged to the window is not supported"
;;
esac
;;
\?)
echo
;;
esac
done
Save it somewhere (I like using joshuto's config folder) and make it executable.
It should be called with a keymap. Pass -e for "export mode" or -t for target mode.
{ keys = [ "D", "e" ], command = "spawn /home/user/.config/joshuto/scripts/dragon-drop.sh -e %s" },
{ keys = [ "D", "t" ], command = "spawn /home/user/.config/joshuto/scripts/dragon-drop.sh -t" },
The only time I don't choose Joshuto for file management tasks is when I have to drag and drop some files into a webpage on my browser, and that's the only reason I keep pcmanfm, however it feels wrong to keep an extra program and switch programs just for that one quick step. Would it be possible to implement drag and drop with mwh/dragon, maybe as a plugin? It looks like jarun/nnn has an implementation that may be useful to peek at. Maybe we could make some glyph (or even the entire region) clickable, to drag the currently highlighted files.