Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 01 Sep 2014, 17:39
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
How to add a new MIME-type (file extension type) in Puppy
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message
mcewanw

Joined: 16 Aug 2007
Posts: 2338
Location: New Zealand

PostPosted: Fri 20 Nov 2009, 20:23    Post subject:  How to add a new MIME-type (file extension type) in Puppy  

How to add a new MIME-type (file extension type) in Puppy

The Theory:

In Puppy, clicking on a Rox file icon usually results in an appropriate default application automatically opening the file. The MIME-type of the file determines which default application should open. The mechanism is described at the ROX website http://roscidus.com/desktop/taxonomy/term/16 as follows:

Quote:

File types and icons
Category:

* MIME types
* Theming

How does the filer decide what icon to show for a file, and which program to use to open it?

For each file, the filer starts by working out its MIME-Type, as follows:

* If the file's user.mime_type extended attribute it set, then that is its MIME type.
* If the file's name matches a pattern in one of the globs file (usually, /usr/share/mime/globs) then the line in that file gives the type.
* If the contents of the file match a pattern in one of the magic files (usually, /usr/share/mime/magic) then that gives the type.



[Disclaimer: If you do any of the following you must accept to do so at your own risk!]

The Method:

1. If you have a file with a MIME-type unknown or unhandled by Puppy Linux you can add the new type to the end of the file /usr/share/mime/globs
[NOTE: What I am suggesting requires that you ignore the warning given at the top of that file not to modify it manually. BarryK seems to have done likewise...].

2. /usr/share/mime/globs is a text file which can be opened and edited with any standard text editor (such as Geany or NicoEdit).

However, before modifying globs you should always check (using your editors search/find function) to make sure that it doesn't already contain an entry for the extension/mime-type you are interested in. If it does, you can jump to step 4.

3. For example, if you have a file whose extension is .tmd
you could add the following entry to the end of /usr/share/mime/globs for it:

Code:
application/x-tmd:*.tmd


The x- in the MIME-type name above is used to indicate that this type hasn't already been
registered with the MIME-type authorities (www.iana.org/assignments/media-types/). i.e. It is a private/local type, not an IANA officially registered one.

Files of type .tmd are actually used by the SoftMaker Office wordprocessor program called TextMaker. For this example, I assume the Linux version of that program (for MS windows versions of programs that require "wine" to run under Linux, see the wine-related link at the end of this howto for some additional information required to execute the appropriate wine applications for the file type concerned).

!!! NOTE WELL that if you do add any new entry to the globs file, you should take care to make sure that your end the file with a single carriage return, or it won't work properly.

4. You now need to create an executable shell script in /usr/local/bin, which for this example I will call defaultRunTextMaker (though you can call it anything you like), for starting up the TextMaker program.

It should contain the following lines:

Code:

#!/bin/sh
exec /path_to_where_the_program_is/TextMaker.exe "$@"


You don't need the /path_to_where_the_program_is/ part if that directory is already in your Linux PATH environment variable.

5. Finally, you need to tell ROX to open that default Run script should you click on a file of that mime type. To do that you create a short executable shell script in ~/Choices/MIME-types named, for this example, application_x-tmd, which should contain the lines:

Code:

#!/bin/sh
exec defaultRunTextMaker "$1"


!!! NOTE WELL that you DO NOT (and should not) need to set a default Run Action after doing the above; fixing the mime type information was enough. i.e DO NOT right click on the file icon in order to forcibly enter a shell command for the file type; instead leave everything up to the above mime type mechanism.

5b. EDIT: Having said the above, once you have modified the /usr/share/mime/globs file, you COULD alternatively not bother about the above step 5 code at all and just set a Run Action for the file type by right-clicking on the file icon and entering the appropriate shell command (e.g. path_to_TextMaker "$@"). That will automatically create an appropriate application_x-tmd shell script, but ROX stores that in ~/.config/rox.sourceforge.net/MIME-types rather than in ~/Choices/MIME-types. Either way should work I think. However, if you have, for example, an application_x-tmd shell script in both ~/.config/rox.sourceforge.net/MIME-types and in ~/Choices/MIME-types, then the one in ~/.config/rox.sourceforge.net/MIME-types takes precedence (i.e. ROX seems to look there first). The right-click Set Run Action mechanism thus provides a convenient means of quickly (permanently or temporarily) over-riding a previously set up default mime handler (in ~/Choices/MIME-types) for a given file type.

6. That is it!

Now any file with the extension .tmd should be recognised as having MIME type application/x-tmd. [Right clicking on the file icon and selecting Properties shows you the mime type the file is being recognised as].

The appropriate Linux TextMaker application should thus be automatically opened on clicking the .tmd file icon.

[Note, however, that you may need to close the ROX window and reopen it before clicking on the app icon after first doing all the above; I can't remember. I certainly did not need to reboot though].

For a more complicated example, involving two MS applications running over wine, see this post/thread here: http://www.murga-linux.com/puppy/viewtopic.php?p=363429#363429

As forum member davids45 comments in the above "wine-user" related thread:

davids45 wrote:

Creating the specific application_x now means I can use an icon for all files of the particular application without other file types also getting iconified incorrectly. The upper button option of the "Set Icon" right-click menu shows the new application type.

_________________
Non enim propter gloriam, diuicias aut honores pugnamus set propter libertatem solummodo quam Nemo bonus nisi simul cum vita amittit.
Back to top
View user's profile Send private message Visit poster's website 
theinfamousj

Joined: 03 Sep 2006
Posts: 85

PostPosted: Wed 30 Nov 2011, 21:46    Post subject:  

Great tutorial. I expanded (or perhaps contracted?) on this in an "explain like I'm five" tutorial for setting up your own MIME file type for the sole purpose of assigning an icon. It can be found here:

http://theinfamousj.tumblr.com/post/13433505685/puppy-linux-adding-new-mime-filetypes

and has lots and lots of pictures for those who aren't as technologically savvy as the rest of us.
Back to top
View user's profile Send private message 
darkcity


Joined: 23 May 2010
Posts: 2444
Location: near here

PostPosted: Mon 06 Feb 2012, 15:36    Post subject:  

I've added alot of the info here to

http://puppylinux.org/wikka/AssociateFiles

along with right-click association

; -)

_________________
helping Wiki for help | IF SendSpace link = "dead" THEN PM me ("up file to http://meownplanet.net/")
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0660s ][ Queries: 11 (0.0041s) ][ GZIP on ]