Search code examples
c++linuxgnomenpapi

Starting default application for a file on Linux


I'm working on a Firefox NPAPI plugin + XPCOM component. I've run into a dilemma: Given a file downloaded from the Internet (say a PDF or PNG) how do I start the default helper application to display that file on Linux using C/C++?

Currently I'm using the system function call to invoke the gnome-open command and passing it the file path. This works on GNOME Desktops, however it won't work across Linux platforms with different desktop environments (including KDE).

So my question is: Is there a standard uniform method to go about this? Are there any recommendations? Any help would be greatly appreciated!


Solution

  • The xdg-open command is the standard way to open a file or URL in the user's preferred application.

    It should work correctly in different desktop environments.