mwh / dragon Goto Github PK
View Code? Open in Web Editor NEWDrag and drop source/target for X
License: GNU General Public License v3.0
Drag and drop source/target for X
License: GNU General Public License v3.0
I've realized a strange behavior with qutebrowser and dragon --target
, seems that the drop option only supports links prefixed with file:
When used with symlinks, dragon points to the target, rather than the symlink itself.
touch a
ln -s a b
dragon *
Observed behaviour: dragging either a
or b
results in the output of a
.
Expected behaviour: dragging b
should result in the output of b
.
I think there should be an option to interpret the input as the data itself, rather than converting it to file URIs. It's a bit asymmetrical that you can select and drag plaintext from a browser or some other graphical app into dragon
, but not out of it.
When I click on the window and it opens the file, I would expect the window to close as it would if the contents were dragged. (Probably would respect the --keep
option)
Currently, it opens a new window which takes focus and I have to change the focus back to dragon-drop
to close the source window.
$ touch -- a b -i
$ dragon *
The dragon window only show files a
and b
, using -i
as the option (i.e. --icon-only
).
dragon should interpret -i
correctly as a file, not as an option. This could be by a --
option, i.e.
$ dragon -- *
Make the window is always on top so that be convenient to drag to other windows.
Currently dragon cannot handle combined flags in the arguments passed to it on the shell, for eg:
dragon-drag-and-drop -tk
dragon launches with -t
and -k
flags
dragon returns the following error
dragon-drag-and-drop: error: unknown option `-tk'.
Usage: dragon-drag-and-drop [OPTIONS] FILENAME
This can be fixed by using the standard getopt C library. I'd be happy to write PR for the same.
Amost every tool accepts standard filepaths as an argument or thorugh stdin, however dragon always outputs a file's URI in target mode. Currently I need to pipe dragon's output through a custom script to get the useful filepaths instead of the URIs and I can imagine this to be a common use case.
Hi, I would like to add a new flag (can't find a good name for it) to supplement the --and-exit
flag. Currently, if I have multiple files "served" by dragon with the -x
option, then dragon doesn't wait till i drag all the files to respective apps. It closes on the first drag_end
event.
I would like to add a -X
or --individual-exit
(name could be improved) that will:
drag_end
eventI know the -a
option exists but my workflow consists of me having to drag different files to different applications.
I have the code changes ready and can create a PR if the maintainers are interested. Please let me know if you have any questions
Thanks
The name of this conflicts with the kde media player also called dragon.
I guess you could just try to work without one of the two, but that's not good practice.
I suggest changing the executable name to something like xdragon, that would also fit with xclip or xdotool since they are also small x utilities. Or you could just rename the project as a whole. Maybe the change would also enable it to get into the repos of some distros.
Hi, I'd like to package dragon for Void Linux since dragon is pretty useful in conjuction with terminal file manager I use
Void requires some version number for packaging. I'd be very grateful if you could create tag for lastest commit (v1 or something like that).
You can do this with
git tag v1
git push --tags
Cheers :)
I understand why is it coded like that, it's very effective, but, when it comes to some naming conventions like timestamps, for example some-series-i-was-watching.mkv_[00:19:35.257].png
gets interpreted as a uri
I have dragon
on a keyboard shortcut in my terminal, and dragon --target
on another shortcut. But I would rather have just one shortcut. Is it possible to have one command that supports drag-and-drop in both directions?
Here's one I wrote for myself: https://github.com/indigoviolet/homebrew-tap/blob/main/Formula/dragon.rb, if you want to incorporate it or provide it yourself.
Hi, thanks for this very useful program.
I've a problem since few months, sometimes when I drag a file the plus icon on the mouse doesn't appear and the whole GUI freeze, I have to kill dragon for get hand back on GUI.
I'am on arch linux with i3.
I'm sorry because I've no idea why it crashes sometimes, and sometimes not, with the same file...
I tried with dragon -v file
but not learn anything, if you have ideas...
Thanks
I get a segfault when trying to drag+drop an (utf-8 encoded) text file.
If hat matters, on startup I get the following warnings:
(dragon:26094): Gtk-WARNING **: 18:06:12.639: Could not find the icon 'text-plain'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:
http://icon-theme.freedesktop.org/releases
(dragon:26094): Gtk-CRITICAL **: 18:06:12.639: gtk_icon_info_load_icon: assertion 'icon_info != NULL' failed
VERSION "1.2.0"
Diff -e below:
560,561c
add_target_button();
for (int i=1; i<argc; i++) {
if (argv[i][0] != '-' && argv[i][0] != '\0')
add_filename_button(argv[i]);
}
gtk_widget_show_all(window);
gtk_main();
exit(0);
.
387,392d
155c
label = g_path_get_basename(label);
When opening multiple files, there might be the case that one file might not be of interest anymore (even without it being dragged at all).
I suggest to add an option to remove a file e.g. on right-click of the entry.
Consider this case in which the last ten files of a folder are listed: dragon-drop $(ls -tr | tail -n10)
I suggest adding an option that refreshes the list (e.g. removing files not existing anymore and adding new files from a folder automatically.
I know there is --stdin
but I wasn't able to get this functionality using this.
Hi @mwh, first of all THANK YOU! I was lookgin for something like dragon for a long time... really really thanks.
Do you think it will be possilbe to have dragon support a select all or select region for files in window? I found most of the times I just need to attach 4/5 files to an email, for example, and I'd like to be able to select all from dragon window and drag them into the browser.
Would implementing thumbnails into this program be possible?
TIA.
I'm assuming this is a UTF-8 issue, but dragon doesn't work with all characters. For example,
touch a b a∩b
dragon *
a
and b
work as expected. However, you cannot drag a∩b
. You can click on it to open the file, but dragging it results in no output.
In addition, the file itself doesn't have to have these characters in it for dragon to fail. It's sufficient for them to be in the path at all. i.e.
mkdir a∩b; cd a∩b
touch foo
dragon *
This will fail as above.
Currently, each file is displayed as a fairly large icon (or preview if available) alongside the full path.
Here are a few suggestions, that in my opinion would allow for better customization:
--no-thumb
don't show preview thumbnails, use file icons for all files--icon-size
to go along with --thumb-size
--font-size
already requested in #30--verbatim-arguments
show the file names exactly how they were passed on the CLI instead of normalizing to an absolute path (so dragon-drop foo
will show foo
, dragon-drop ../dir/foo
will show ../dir/foo
, etc)Here's a mock up of dragon-drop --no-thumb --font-size 28 --verbatim-arguments bar baz download.jpeg foo
:
What I would like to see is an additional flag that goes alongside -a that combines file objects into a much smaller single object that takes up less screen space and maybe lists how many files are in the selection and the total size of the selection or something.
For some reason, Discord doesn't accept files dragged from dragon. However, it does accept file from Nautilus and Nautilus (and FireFox) also accepts files from dragon. Any clues as to what might be going on? Is Discord at fault?
To be clear, when dragging to a Discord client, the normal on-hover popup displays but when you release the mouse button, the popup just disappears and nothing happens. Not even an error message in the console.
Hi, thanks for dragon.
No issue here just a note: This is may be of use for someone else as well (just realized I got a few points at SO for it, so why not share):
Function: Hotkey to start script -> select area -> click into drop area. Done.
It uses scrot to make a screenshot of a selected area, then dragon, to create a drag window top left, then xdotool to click and drag that to the point where you click.
Here the script
2.bin$ cat drag_into
#!/usr/bin/env bash
doc="$0 <filename|'shot'>
Drags a given file to where the mouse is using dragon. Click to drop it (anywere).
If filename is 'shot' then the file will be a shot of a an area to be selected
(i.e. ideal to be triggered by a hotkey).
"
cmd_shot="shot"
file=
exit_help () { echo -e "$doc"; exit 1; }
select_shot_area () {
# create screen shot
notify-send "Select area - we'll shoot it and drag to where the mouse is."
cd "$HOME/Pictures/shots/" || exit 1
rm -f "latest.png"
scrot -s '%Y-%m-%d_$wx$h_scrot.png' -e 'ln -s $f latest.png'
file="`readlink latest.png`"
}
main () {
file="$1"
test -z "$file" -o "$file" == "-h" && exit_help
eval "$(xdotool getmouselocation --shell)" # into $X and $Y
test "$file" == "$cmd_shot" && { select_shot_area || return 1; }
killall dragon 2>/dev/null # No accidential drops of wrong items ...
dragon --and-exit "$file" &
while true; do
xid="$(xdotool search --onlyvisible --class dragon | head -n 2)"
test -z "$xid" || break
sleep 0.05
done
xdotool mousemove --sync -w "$xid" 1 1 mousedown 1 mousemove $X $Y
notify-send "Click to drop $file..."
}
main "$@"
so I have no problem in draggin files out from my terminal into an other app, the problem is when I try to drop using
dragon --target --and-exit
because it just prints the name of the files but does nothing
I am currently in arch linux and I have tried compiling it from source, also tried using bouth of the packages in the AUR but I still have the same problem. any guesses?
Would it be considered "in scope" to add an optional flag that sets the font size?
Allowing to specify a font name might be a bit of a stretch, but will certainly increase dragon
's popularity amongst /r/unixporn.
In Ubuntu 22.04 with i3wm after compiling and installing the binary in the default location I get completions only for directories, that is, if I press after dragon<Space>
in the shell, only directories are auto completed.
I solved this issue by using a custom completion command for dragon:
complete -o default -o bashdefault dragon
Can this behavior be implemented by default?
For Arch Linux users, can you please indicate in readme that the project is available in dragon-drop package? Here it is:
https://aur.archlinux.org/packages/dragon-drop
I tried to drag some utf-8(persian) text while running dragon with --target
but this was printed:
ÙÙØªÛ ÙÙÙز Ù
ردÙ
Ù
ا تÙÙÛÙ
ÙشدÙد ØÙÙ
عÙÛ ÙرÙØ·ÛÙ٠را ÙÙ
Û Ø¯Ø§ÙÙد ØÙباÛد تÙÙع داشت کرÙÙا ب٠اÛ٠زÙØ¯Û Ø§Ø² Ú©Ø´Ùر Ù
ا برÙدØبÛÙ Ù
رÛضÙØ§Û Ù
٠اÙØ±Ø§Ø¯Û ÙستÙد ðÚ©Ù Û¶ÙرÙردÛ٠در
while the original text was:
وقتی هنوز مردم ما تفهیم نشدند ،ومعنی قرنطینه را نمی دانند ،نباید توقع داشت کرونا به این زودی از کشور ما برود،بین مریضهای من افرادی هستند 🌀که ۶فروردین در
When dragon-drop is called multiple times, it opens up a new window every time.
It would be nice if it there was an option to just append the file list.
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.
Is it possible to select and drag multiple files from the dragon window?
Is it possible to resize the dragon window?
Currently, it prints the complete path of the file as entry. It makes it cumbersome to place the window around. Is it possible to somehow resize the window to line-wrap the entries (so window size is grown vertically not horizontally)?
Excellent project BTW 💯 😃
Hello. I switched to sway few weeks ago. Im in love with CLI-tools, that allow me to drag&drop from CLI, but im expiriencing troobles with that on Wayland. Drag window shows up, but i cant drop anything. Sometimes i can, sometimes - cant. Can u suggest some solution for me? Or, at least, tell me, how to debug it properly.
Also, your app gives me error:
(dragon:161804): Gdk-WARNING **: 14:59:50.047: Error writing selection data: Error writing to file descriptor: Broken pipe
If this error is related to my bug - how can i enable moving popups? Is that even possible?
Demonstration:
shift+click and control+click and control+a for selecting multiple items in the dragon window to drag OUT of the window
It works great for everything else, but say I wanted to drag like 10 files at once into something? If I select them all in ranger and then use dragon to pop up a window to drag them somewhere, I always have to then drag them somewhere 1 at a time.
Thoughts?
I might try to do this at some point myself but I would have to learn c first.....
It might be a good reason for me to learn some c though so I would welcome the challenge if people want this.
Or if someone who knows the project would be able to add this in an evening I would be extremely grateful
I'm trying to use dragon with a file selector dialog such as yad or zenity.
Both give me the same error:
dragon -x "'$(yad 2>/dev/null --file)'"
dragon -x "'$(zenity --file-selection)'"
The file `/home/arif/'/home/arif/Downloads/remove-red.png'' does not exist.
(Using the funny quoting in an attempt not be disturbed by paths with spaces)
Will this program support Wayland in the future, or is there a Wayland alternative?
When there are a lot of files, the window goes off screen, instead there should be a check to limit the size of the window (if possible), and there should be a scroll bar.
It's always possible to shrink the window, but then you can't access lower items, so a scrollbar is necessary.
Anyone aware of a tool that does what Dragon does on MacOS? I know this is off topic but I figure if anyone would know, it would be the people here.
Hi there, starting dragon-drop from a wayland terminal breaks the --and-exit feature.
The popup still stays on screen, even if you drag the file somewhere.
Starting it from a terminal using X11, it works.
How can I ensure that dragon-drop is always started under X11?
I've been using this for a while
https://github.com/rkevin-arch/CLIdrag
the behaviour is pretty simple:
$ drag FILES
my cursor changes and I just drag, no need for the extra step of creating a window and dragging from there, can I do that with dragon-drag? If not, is there any plans to add that?
When I use the --on-top option, still the window is not kept above others. This is in Plasma on Wayland session.
I wish dragon
stayed on top even when I switch workspaces
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.