3

I like to integrate a application (a digital shredder, a interface for shred command) to allow drag-and-drop files from Nautilus to launcher icon and then open the program and fill the file path field. This is possible? I guess I need some code. The program is written in Python.

1 Answer 1

1

There is some simple drag-and-drop support built into Unity. If an application can take a filename as a commandline argument, you simply need to use a variable in the Exec field of the desktop file.

Take for example Gedit's desktop file (with some content removed for readability):

[Desktop Entry]
Name=gedit
GenericName=Text Editor
Comment=Edit text files
Exec=gedit %U
Terminal=false
Type=Application
StartupNotify=true
MimeType=text/plain;
Icon=accessories-text-editor
Categories=GNOME;GTK;Utility;TextEditor;

If you drop a file on a Gedit launcher in Unity, the %U will be replaced by the file's uri.

The variable is part of the Desktop Entry Specification:

  • %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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .