For example, Windows starts a new process of the selected application and passes the name of the file to be opened to the process with an additional command line argument (for my app: argv[0] - executable file, argv[1] - openable file). Ubuntu launches my application, but the process does not receive any additional arguments (only argv[0]). How can my application find out the name of a file that a user opens?
1 Answers
The file manager will pass along the URI of the file that you right-clicked in order to select "Open With".
In linux desktops, applications are launched using a launcher file. A launcher file is a plain text file with the .desktop
extension. It contains information for the desktop environment on how to start the application, what icon to use, how and where to display it in the menu, etc. The Open With Other Application" list in Files (nautilus) is populated by the
.desktop` files present on your system.
It is in the .desktop
file on the Exec=
line that arguments are defined. For example, for the editor Gedit, this line is
Exec=gedit %U
Only when the Exec=
entry of the .desktop
file contains an argument, the system will pass the argument it received from Files (nautilus) to the program.

- 88,010