Sunday, February 3, 2013

Custom command for "open with" in Fedora 18

Suppose I want to open ~/Documents/help.chm with executable ~/Downloads/xchm 

First find out the MIME type of the file:

1. Right click help.chm and select "Properties" option.
2. In the popup, select "Open with" tab.
3. Select a known application, say, "Archive Manager" and click OK.
4. Now look in ~/.local/share/applications/mimeapps.list and find out the MIME type of the file.

Issue the following command and note down the mime type of the file:

file -i help.chm

I found an entry called "application/vnd.ms-htmlhelp"
Now I know the MIME type of help.chm.

5. Create either the file /usr/share/applications/xchm.desktop OR the file ~/.local/share/applications/xchm.desktop and add the following lines:

[Desktop Entry]
Encoding=UTF-8
Name=xCHM
GenericName=chm file viewer

Exec=/home/UserName/Downloads/xchm
Icon=/home/UserName/Downloads/xchm.xpm
Terminal=false
Type=Application
MimeType=application/vnd.ms-htmlhelp;
Categories=Utility;


6. Issue the command update-desktop-database .

Now you can simply double click help.chm or any other .chm file and it will automatically open with /home/YourUserName/Downloads/xchm.

No comments:

Post a Comment