Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

(I'm on Arch Linux, using i3 as my wm and xterm as my terminal emulator, though I don't know if any of that is relevant.)

Occasionally, a website asks me to drag a file with my mouse from my desktop into the internet browser's window. Almost always, there is an alternative, but recently I found something I want to do that requires the drag and drop. Unfortunately, I don't have a file manager. I navigate my computer's file system solely through bash.

Is there a way I can fake the drag and drop action? Can I tell my browser "I just dropped this file onto you" without actually doing it?

Worst case scenario, I can download a graphical file manager exclusively to drop files into my web browser, but I'd like to avoid that solution.

share|improve this question
> Can I tell my browser "I just dropped this file onto you" without actually doing it?" Sounds like a great question for the javascript community on stackexchange. –  jayhendren Jun 18 at 19:52
Also see www:mechanize or a derivative. There is perl and python it seems. The more solutions the better! –  illuminÉ Jun 18 at 20:57

3 Answers 3

up vote 21 down vote accepted

Thanks to @derobert for recommending the Dragbox application to me.

Dragbox does exactly what I need. For example, I have a folder with a number of .png files that I would like to be able to drag into Chromium. Inside that folder, executing dragbox *.png creates this window:

A GUI window with the names of several files listed

I can use my mouse to drag files from there into Chromium, and it works flawlessly. However, getting to this point was a pain. As far as I am aware, Dragbox only officially supports Debian systems. I couldn't find it anywhere that natively worked for Arch. So, I've written a step-by-step guide to getting Dragbox working in Arch Linux. This is almost exactly what I did on my machine, with a couple modifications to follow better practices. If there's an error somewhere, you can look in this answer's edit history to see exactly what I did on my machine.

  1. Clone Dragbox's source to your computer by executing git clone https://github.com/engla/dragbox.git
  2. There will be a new directory called dragbox created inside your current working directory. Go inside.
  3. Dragbox and Dragbox's installation require Python 2, which comes standard on Arch Linux. However, it expects Python 2 to be the default Python installation, which isn't true on Arch. Get around this by executing export PYTHON=/bin/python2. Until you close your current terminal window, the environment variable $PYTHON will have the value /bin/python2. Dragbox's installation scripts check for that, and will use it over Python 3.
  4. Execute ./autogen.sh, ./configure, make and make install. make install must be done with root privileges (e.g. sudo make install).
  5. Dragbox is now installed on your computer, but is going to try to use Python 3 to run. With root privileges, open /usr/local/bin/dragbox in a text editor. Modify the shebang (the first line, that tells your shell what executable to run the script with) from #!/usr/bin/env python to #!/usr/bin/env python2.
  6. The script is now working, but it can't find the module containing the actual program. There are a couple of ways you can fix this.

    1. Include in your ~/.bashrc or similar a line reading export PYTHONPATH=$PYTHONPATH: immediately (as in, not even a space between) followed my the path to a directory. Python will now look in that directory when trying to import modules. Inside the directory created back in step 1, there will be a directory called Dropbox/ (with a capital D). Copy that directory to the directory you added to your $PYTHONPATH (e.g. if you wrote export PYTHONPATH=$PYTHONPATH:~/python/modules, copy the Dragbox/ directory to create ~/python/modules/Dragbox/).

    2. Probably worse practice, but you can copy that same directory to a directory already in your $PYTHONPATH. For example, you could copy it to create /usr/lib/python2.7/site-packages/.

If you've followed these steps, Dragbox should be working! You can now execute man dragbox to learn more about how to use it, and launch it by simply typing dragbox.

share|improve this answer
Wow, that's awesome! –  Seth Jun 18 at 21:50
Actually, using /usr/bin/env python2 is the recommended way these days, since PEP 394 got adopted. –  Gilles Jun 18 at 23:13
You don't need the second fix. Simply copy the Dragbox directory into the PYTHONPATH somewhere (like in the python2 site-packages, either system or per-user). That line is executed only when dragbox cannot import that package. –  Bakuriu Jun 19 at 11:21
@Seth Well, thanks I guess. I made a python script run on a slightly different system than it was designed for, that still had python on it :P I'm glad it was python, though, since that's the only language I'm fluent enough in to have made this happen. –  undergroundmonorail Jun 19 at 14:26
With Archlinux, the real solution for this type of thing is to wrtie a PKGBUILD. You largely do what you've done, but you put it into a special script that allows pacman to manage the files for you so you don't ever have to go mucking around in the system should you want to update or remove it. –  HalosGhost Jun 20 at 7:06

You can easily navigate the filesystem within your browser, using the syntax:


Open the path in an empty tab and from there you can drag and drop your file. At least with chrome/chromium, don't have other browsers here to try.

share|improve this answer
This isn't working for me, but I can't tell if it's a problem with the method you describe or a problem with the userscript that wants me to drop stuff in... –  undergroundmonorail Jun 18 at 20:18
I think there's a command line switch or a attribute within chrome you have to enable to allow this. –  slm Jun 18 at 20:22
Would chrome://flags be the right place to look for something like this? That's where I'm looking at the moment. –  undergroundmonorail Jun 18 at 20:28
@undergroundmonorail mmm you're right, I just tried with the demo at dropzonejs.com and it doesn't work. Could definitively be a permission problem, though –  Mr Shunz Jun 18 at 20:30

I had exactly the same problem a few months back and ultimately just wrote a tool to do it for me. When I saw this and found someone else had the same itch I cleaned it up so that someone other than me could actually get it running, and finished off my to-do list. The code is up now: https://github.com/mwh/dragon

To get it, run

git clone https://github.com/mwh/dragon.git
cd dragon

That will give you a standalone dragon executable - you can move it wherever you want. make install will put it in $HOME/.local/bin.

Either way, you can then:

dragon *.jpg

to get a simple window with draggable buttons for each of those files:

Screenshot of dragon showing a few files

You can drag any of those into a browser, a file manager, an editor, or anywhere else that speaks the standard drag-and-drop protocol.

If you want to go the other way, and drag things in to it, use --target — they'll be printed to standard output, or available to drag out again with if you use --keep as well.

To build you'll need a C compiler and the GTK+ 3 development headers - if you're on Arch you'll get those just by installing GTK+, but on other distributions you may have to apt-get install build-essentials libgtk3-dev or yum install gtk3-devel or similar first. Other than that it's entirely self-contained, with no constituent libraries or anything, and you can just put the executable where you want.

My use case is mostly one-off drags of only a few files (usually just one), without particularly caring how they show up, so if that doesn't line up with what you want then Dragbox (which I didn't see until recently) might still be better for you. Just yesterday I added the support for using it as a drag target as well, so that part hasn't had much use on my end. Other than that, though, I've been using this successfully for a while now. There are other modes and options described in the readme file.

share|improve this answer
Thank you! It took seconds to build/install! I'll use that! The --target option is a blast! –  illuminÉ Jun 21 at 4:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.