How to handle file when dragged on to application icon


Hi there,

How can I handle files that are dragged on to an atom-shell app?

I was hoping the following might do the trick, but no luck:

app.on('finish-launching', function() {
	app.on('open-file', function(event, path) {



Files dragged on to the icon are handled exactly the same as files opened from File > Open. You should use atom.workspace.addOpener to register a function that will be called when files are opened. Your function can then check the path and return a view if it wants to handle it, or nothing to continue looking for openers.

atom.workspace.addOpener(function(uri) {

Note the docs appear to be incorrect atm, it says atom.project.addOpener but it should be atom.workspace.addOpener.


Thanks for your answer, but I am talking about Atom-Shell, not Atom itself…


Atom-shell should be a different forum. I’ve made this mistake several times.

Atom Shell should be a different forum?

oops… my apologies!

So, if this is on OS X, you also need to specify the file types your application accepts in the Info.plist. See the plist for atom here:

The key is CFBundleDocumentTypes. e.g. to accept jpg files, add this to your Info.plist:


Once I added this dropping onto the application icon worked and logged the filename. OS X may cache the plist, you can clear the cache by moving the application somewhere else and back again.


The following solved it for me in combination with postcasio’s answer (thanks!):

var app = require('app');
app.on('open-file', function(event, pathToOpen) {