Revision [22129]

This is an old revision of AssociateFiles made by darkcity on 2012-07-09 15:38:12.

 

HomePage > Components and HowTos > Configure

How to make File Associations

There are a few ways to associate file-types to programs in Puppy. The following descriptions are based on the ROX Filer and may not work with other file managers.
Sometimes you won't be able to associate a file to a program because its MIME-type has not been defined. Looking in the file's Properties > Type will reveal only a general type (guessed by its content) - for example text/plain or application/x-executable. In this case you need to add a mime type.

Default Action
Default Action loads the file into the appropriate program when it is clicked (left-clicked) depending on its MIME-type. ROX will look for file named after the MIME type, firstly in-
~/.config/rox.sourceforge.net/MIME-types/[MIME-type] then
~/Choices/MIME-types/[MIME-type]
For example, if the MIME-Type is application/x-audacity-project
then ROX will look for a file called application_x-audacity-project (notice the / is replaced by an _).
Typically this file is a script of a link to an executable. Often it is a link to a program's .Desktop stored in /usr/share/applications.
ROX provides a graphical way to set Default-Action


Right-click Association
Right-click Association loads the program when the user goes - Right-clicks menu > File 'document.doc' > Doc program

Open-with Association
Open-with Association loads the program when the user goes - Right-clicks menu > File 'document.doc' > Open With > Program



MIME-Types are used to standardised file-types. The 'Right-click' options are stored in
/root/.config/rox.sourceforge.net/OpenWith

There is a directory for each mime-type in use, for example the MIME-Type directory for image/jpeg becomes .image_jpeg
A shortcut for making a 'right-click' association is in the example of a jpeg, 'right click' on a jpeg file and select
File 'filename.jpg' > Customise Menu ...
Open /usr/local/apps and copy an absolute link of the program you wish to associate



'Default Action' Association
To set the 'default action' of a file-type follow the following instructions (modified from this thread). Jump to Step 3 if you wish to associate with program already installed.

1. Check if your file-type has a MIME-type entry in Puppy Linux. They are stored in the text file /usr/share/mime/globs
If file-type is already associated to the correct MIME-type jump to step 2.
Add or edit your MIME-Type to file-type definition. For example, if you have a TextMaker file whose extension is .tmd and your making a non-standard MIME-type application/x-tmd append the code :*.tmd to the globs file. ENSURE you end the line with a 'return' otherwise it won't work.


2. Create an executable shell script in /usr/local/bin , for starting up the TextMaker program and passing the 'clicked on' file to it. In our example, .tmd files will be associated to TextMaker. We'll make a script called textmaker (though it could be anything you like):
textmaker -
#!/bin/sh
exec /usr/local/textmaker/tml "$@"

You don't need the path to the executable (in this case /usr/local/textmaker/) if the path directory your Linux PATH environment variable.
If textmaker was a WINE program then the script might be-
textmaker -
#!/bin/sh
# Purpose: To convert Unix filename to DOS style to pass as an argument
# to wine when starting IrfanView from filer.
#
FileName="z:"${1//\//\\}
exec wine 'C:\\Program Files\\TextMaker\\TextMaker.exe' $FileName



3. Finally, tell the ROX filer to run that script when you click on your file-type. To do that you create another script in /root/Choices/MIME-types named after the MIME-type. In our example the MIME type was application/x-tmd, so the file becomes application_x-tmd-
application_x-tmd
#!/bin/sh
exec textmaker "$1"

An easy way to associate a file-type with a program is (instead of step 3). is to use 'Set Run Action' i.e right click on a file of your type and enter the shell command/ or drag program on to box. In our example it would be exec textmaker "$1".



There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki