LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Get program based on mime-type in C (https://www.linuxquestions.org/questions/programming-9/get-program-based-on-mime-type-in-c-788310/)

nwarrenfl 02-10-2010 02:52 PM

Get program based on mime-type in C
 
Hello everybody!

Here is my problem:
I need to launch programs in my program and the program can be a script, a Linux executable or even a Windows executable (don't ask why).

The first thing i tried is to use xdg-open from my program, but i can't pass arguments to it, otherwise it would have worked perfectly.

Is there maybe a way to determine which program is set as default according to the mime-type of the program i want to launch?

I also tried kfmclient and gnome-open, they don't allow arguments either.

Help me, thanks!

MTK358 02-11-2010 08:14 AM

See fork() and exec().

MTK358 02-11-2010 11:35 AM

As for the part where it should choose the program, I am not sure if that's really practical. Linux does not have a built-in table of file type-program associations, because Linux existed before GUIs and in the command line, you specify the program you want every time.

I think that desktop environments like GNOME, KDE, and Xfce have their own way of storing file/program associations, I guess you could do that but that would make your program rely on the user having thers environments installed.

Another option could be letting the user choose what file types should be opened by which program, in either a GUI settings dialog or a plain text config file.


All times are GMT -5. The time now is 09:06 PM.