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.

In Windows you can drag and drop a file into an executable and the executable will be launched with the file as it's first argument.

Is such functionality possible on Linux?

I'm using OpenSUSE 12.1 with KDE and Konqueror as the file manager.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

From this answer at askubuntu.com which refers to some freedesktop.org spec, I gather what you're looking for is possible by creating a .desktop file with an EXEC= entry. I suppose the recognized field codes (e.g. %u) get replaced with the dropped file's URI/path:

%f A single file name, even if multiple files are selected. The system reading the desktop entry should recognize that the program in question cannot handle multiple file arguments, and it should should probably spawn and execute multiple copies of a program for each selected file if the program is not able to handle additional file arguments. If files are not on the local file system (i.e. are on HTTP or FTP locations), the files will be copied to the local file system and %f will be expanded to point at the temporary file. Used for programs that do not understand the URL syntax.

%F A list of files. Use for apps that can open several local files at once. Each file is passed as a separate argument to the executable program.

%u A single URL. Local files may either be passed as file: URLs or as file path.

%U A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.

(...but I've neither ever tried this nor do I know if it's supported by KDE, so someone knowledgeable pitching in would be good.)

There might be other ways, via Plasma starter widgets, but I have no idea.

share|improve this answer
1  
Thanks! It works!. It's also worth stating the the .desktop file is not part of the desktop environment configuration - it doesn't need to appear inside a configuration folder. The .desktop file is the file that you drag-and-drop into. –  Idan Arye Feb 27 '12 at 21:04

Your Answer

 
discard

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.