LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2010, 02:52 PM   #1
nwarrenfl
LQ Newbie
 
Registered: Jan 2009
Posts: 18

Rep: Reputation: 0
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!
 
Old 02-11-2010, 08:14 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
See fork() and exec().
 
Old 02-11-2010, 11:35 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Squid redirector/URL rewrite based on MIME type drmouse Linux - Server 0 02-25-2008 05:07 AM
Warning ___ specifies undefined mime type/service type mbvpixies78 Linux - Software 0 12-29-2007 10:25 PM
OOCalc Mime Type FYZ Linux - Software 0 08-25-2005 03:51 AM
Can't find Mime Type cootetom SUSE / openSUSE 20 08-16-2005 01:58 PM
Mime type settings saravanan1979 Linux - Newbie 0 04-15-2002 05:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration