Search code examples
clinuxexecutable

Linux mint drag & drop files on my program's desktop icon


I am using Linux Mint.

I wrote a small program in C and want to drag and drop a file onto its desktop or caja icon. When I drag a file over the icon of an installed application, that app icon highlights showing that it will launch, but my program's icon does not highlight. How do I enable the launch?

In windows all programs launch, even if they don't handle a dropped file.

The program "executable" permission is set, and double clicking the icon does launch it.

I am thinking that it is not something I do "in" the program code, but some configuration for the icon or Linux. The program code accepts command line arguments when run from a terminal. But dropping files on its icon does nothing at all except moves the files to the desktop piled on top of the program icon. Never even attempts to launch the program.

What am I missing?


Solution

  • Now I understand!

    I must create a "launcher" for the program. This is done by right-clicking on the desktop blank area to get the context menu, and choose "Create Launcher...". Then fill in the fields, and especially the "Command:" field with a valid pathname (or just a name if the program is in a directory that is included in the PATH environment variable). AND include at the end of that command line %F to accept the file(s) to be dropped. Also give it a name and click OK.

    If you leave off the %F and drop more than one file, each file will launch its own instance of the program. The %F causes all the files to be passed to one instance of the program. For example if you want to drop two files onto a compare program.

    If it doesn't work, you can edit the command and other fields by right-clicking on its icon and choose Properties.

    It has a generic springboard icon.

    In a terminal, the ls command shows the launch file for "prog" (for example) as prog.desktop but on the desktop just prog. The launcher file can be moved or copied into a folder (other than desktop) and they work the same (although the icon is different).

    Hope this helps others.