LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Make firefox aware of kde apps (https://www.linuxquestions.org/questions/slackware-14/make-firefox-aware-of-kde-apps-615686/)

john-boro 01-23-2008 04:11 AM

Make firefox aware of kde apps
 
Hi, quick question,


Trying out opensuse the other day, I noticed that when downloading (for example) a tar.bz2 in firefox, one option would be to 'open with ark'. This does not happen for me in slackware. I can configure firefox to automatically open archives with ark, but it seems that if I set it to ask me what to do each time, it is not aware of ark as an application. How can I solve this?


Thanks a lot

john

unSpawn 01-23-2008 09:18 AM

About MIME types and .desktop files
 
For any entity your browser can not render internally it will look for an accompanying MIME type. FF recognises MIME types searching through two databases" (type "about:config" and search for "mime"). Customised handling can then be configured in ~/.mozilla/firefox/$PROFILENAME/mimeTypes.rdf. Recognising applications linked to MIME types is done by your Desktop Environment which should honour the Desktop Entry Specification. It dictates each shared MIME type (also see: XDG) is mapped to a .desktop file in the mimeinfo.cache (and defaults.list) and each relevant application has a .desktop file with a "MimeType" entry in it. So if for instance you're looking for "tar" ("application/x-tar") you could check if 'grep -i 'tar=' mimeinfo.cache' and 'grep -i 'tar=' defaults.list' both point to the same .desktop file and if that file exists if it emits the right MIME types 'grep -i mime'.

* Somebody else may know of a more "correct", easier or even GUI way for handling this kind of thing.

john-boro 01-23-2008 10:18 AM

thanks for the information. If I can decipher what it means then I'll give it a go :p

cheers

randomsel 01-23-2008 12:40 PM

Firefox's about:config points to two files: /etc/mime.types and ~/.mime.types, neither of which are present on a clean Slackware install...

shadowsnipes 01-23-2008 02:14 PM

Quote:

Originally Posted by unSpawn (Post 3032572)
* Somebody else may know of a more "correct", easier or even GUI way for handling this kind of thing.

Using the MIME Edit extension might be the easiest way to handle this.

Unfortunately, I don't think it will completely solve the problem.

john-boro 01-23-2008 04:26 PM

yeah, that extension doesn't really help as far as I can tell. You don't get the option "Open this file with Ark" [pretty icon], just "open this file with:" and nothing. Although if I click okay, it does open in ark. weird stuff. Perhaps I can just copy an /etc/mime.types from opensuse??

john

unSpawn 01-23-2008 05:45 PM

Uh. All I'm saying is that maybe how the DE presents a default application for this MIME-type is inconsistent. AFAIK copying mailcap, mime.types or magic.* has *nothing* to do with it since the MIME-type *is* known and a default application *was* offered.
Maybe just read my reply starting at "So if for instance if..."

shadowsnipes 01-25-2008 12:20 AM

It seems to me that the problem is that even though KDE programs know the default apps associated with MIME types, Gtk2 apps like Firefox don't. As figured, Firefox in Xfce doesn't fair any better in these terms.

On Kubuntu, however, Firefox gives a drop down list of apps you can open downloads with in addition to browsing for others. I still don't know how to do this in Slackware (playing with the /usr/share/applications/{defaults.list,mimeinfo.cache} files didn't do anything for me), but at least the MIME Edit extension makes things a little easier.

Also, here's another helpful tweak for firefox that makes browsing for the app easier.

Enter "about:config" in the address bar, look for the "ui.allow_platform_file_picker" key and change its value to "false".

Now you have a more kde friendly file browser in firefox.

Have you actually gotten this working for any apps unSpawn?

drauk 01-26-2008 04:56 AM

Hey i was trying to do this too.
After read the posts and check in "about:config", i copy /etc/mailcap from other distro and if work now i have a list of programs to open with (i tried mime.types before mailcap and didn't work to me),

unSpawn 01-26-2008 06:33 AM

Quote:

Originally Posted by shadowsnipes (Post 3034604)
On Kubuntu, however, Firefox gives a drop down list of apps you can open downloads with in addition to browsing for others. (..) Have you actually gotten this working for any apps unSpawn?

I just tested getting any dummy app to work by adding a .desktop file and mimeinfo.cache references. It then showed the dummy as default app to open with, no other choice and adding it to the defaults.list made no difference. So basically the mechanism kinda works except I didn't get any choice with FF2/XFCE like you said you had in Kubuntu and I'm running neither that or Slackware so prolly MMMV(VM).

shadowsnipes 01-29-2008 01:05 PM

Quote:

Originally Posted by drauk (Post 3035571)
Hey i was trying to do this too.
After read the posts and check in "about:config", i copy /etc/mailcap from other distro and if work now i have a list of programs to open with (i tried mime.types before mailcap and didn't work to me),

Ahh, thanks for the tip. I think I have found one solution for getting this all to work in Firefox in Slackware. You can copy /etc/mailcap from a distro that has this working, yes, but you can also just write the entries you need.

Instead of modifying my /etc/mailcap I chose to modify ~/.mailcap. The default path for mailcap is (as found under the man page)

Code:

$HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap
Here is an example of some lines you can add for getting files to associate with ark.

Code:

application/x-tar;ark %s
application/x-tgz;ark %s
application/x-bzip2;ark %s

Now start up firefox and try opening a tar, tar.gz, or bz2 file. It doesn't work ...yet.

You have to modify mimeTypes.rdf under your firefox profile first. I found the easiest way to do this is to use the MIME Edit firefox extension. Simply add one entry for each corresponding entry of interest in the mailcap (you don't have to do them all).

Now once this is done you should see the default option (ark in this case) come up whenever you try to download or open one of these three archive file types. In addition, if you use the MIME edit extension to specify an alternate program to use for these files, it will now be included as an option. Be sure to check the 'always ask what to do' unless you want the files to be handled automatically. The option selected by default will be the last one selected under the MIME edit extension.

Once you are all setup with this you can simply copy the mimeTypes.rdf file to another profile if you desire.

shadowsnipes 01-29-2008 01:12 PM

Quote:

Originally Posted by unSpawn (Post 3035613)
I just tested getting any dummy app to work by adding a .desktop file and mimeinfo.cache references. It then showed the dummy as default app to open with, no other choice and adding it to the defaults.list made no difference. So basically the mechanism kinda works except I didn't get any choice with FF2/XFCE like you said you had in Kubuntu and I'm running neither that or Slackware so prolly MMMV(VM).

But it worked for Firefox in KDE? Or are you using GNOME? What distro do you have this working in?

Which mimeinfo.cache file did you edit? I have three different ones located at

/home/USERNAME/.local/share/applications/mimeinfo.cache
/usr/local/share/applications/mimeinfo.cache
/usr/share/applications/mimeinfo.cache

I'm assuming you just put the .desktop file in /usr/share/applications.

What do you mean by MMMV(VM)? Is it supposed to be an acronym for something or are you just throwing out some Roman Numerals?

Even though I already got this working using the mailcap I'm still wondering if there are alternative methods that will work.

Mountain 03-14-2012 08:25 PM

Quote:

Originally Posted by unSpawn (Post 3032572)
For any entity your browser can not render internally it will look for an accompanying MIME type. FF recognises MIME types searching through two databases" (type "about:config" and search for "mime"). Customised handling can then be configured in ~/.mozilla/firefox/$PROFILENAME/mimeTypes.rdf. Recognising applications linked to MIME types is done by your Desktop Environment which should honour the Desktop Entry Specification. It dictates each shared MIME type (also see: XDG) is mapped to a .desktop file in the mimeinfo.cache (and defaults.list) and each relevant application has a .desktop file with a "MimeType" entry in it. So if for instance you're looking for "tar" ("application/x-tar") you could check if 'grep -i 'tar=' mimeinfo.cache' and 'grep -i 'tar=' defaults.list' both point to the same .desktop file and if that file exists if it emits the right MIME types 'grep -i mime'.

* Somebody else may know of a more "correct", easier or even GUI way for handling this kind of thing.

I've been researching this issue for a few days. Believe it or not, this old thread is the best reference I have found on the topic. The answer above was really helpful to me. However, it is a gnome-specific answer and the question is about KDE. It would be awesome if someone can add a bit more info from a KDE perspective. The solutions mentioned in this thread didn't solve my problems in Kubuntu 12.04, but the info helped me understand my problem better. I'm still trying to solve it.

In regard to KDE-specific info, for example, /usr/share/applications/defaults.list is apparently not used on KDE (or at least this is the case on Kubuntu, Netrunner, and similar distros). Also /usr/share/applications/mimeinfo.cache is not used.

Here are my notes about the KDE files related to mime-types:

/etc/mime.types <-- present on Netrunner 4.1, Kubuntu 11.10 and 12.04, etc.
/usr/share/applications/mimeinfo.cache <-- NOT present on Netrunner, Kubuntu, etc.
/usr/share/applications/defaults.list <-- NOT present on Netrunner, Kubuntu, etc.
/etc/mailcap <-- present on Netrunner, Kubuntu, etc.
~/.local/share/applications/mimeapps.list <-- present on Netrunner but NOT on Kubuntu.
~/.mozilla/firefox/<profile>/mimeTypes.rdf <-- present on Netrunner & Kubuntu but the contents appear to differ.

Here are the Firefox settings. These KDE settings appear to be different from gnome Firefox settings.
Firefox about:config: helpers.global_mime_types_file /etc/mime.types
Firefox about:config: helpershelpers.private_mime_types_file ~/.mime.types

After tracking down all those files, I'm still missing something. I can't get it to work. What else controls Firefox's recognition of mimetypes in KDE?

Firefox works perfectly in Netrunner 4.1 (which is a customization of Kubuntu 11.10). However, Firefox has the problem described in this thread in Kubuntu 12.04b1 (and, I'm told, also in 11.10 proper). I want to fix this in Kubuntu without switching to Netrunner or OpenSuse.

Another very closely related problem I want to solve is getting Firefox to "Open Containing Folder" of downloaded items.

Since this thread already has good info and a high Google ranking, I would prefer to continue the discussion in this thread. But I also posted a question at Ask Ubuntu: http://askubuntu.com/questions/11219...wnloaded-files

cendryon 03-15-2012 03:26 AM

Hi

I overcome this with xdg-open.
In KDE, I tune the apps I want to open each MIME type in Settings -> File association.
In Firefox, I browsed to /usr/bin/xdg-open the first time FF asked me what to do with a file it doesn't handle.
Now, whichever file Firefox does not handle it opens it with my chosen apps thanks to xdg-open.

I have it working since Slackware-13.0 / KDE 4.2 / FF 3.6 up to Slackware64-current / KDE 4.8 / FF 10.

Hope it helps

Cheers

craigevil 03-15-2012 06:43 AM

OpenSuse and Kubuntu use a package called, you guessed it: firefox-kde-support

Which adds all the nifty mimetypes, makes Firefox use the kde/qt file picker, and other KDE apps.

firefox-kde-opensuse - Gitorious - https://gitorious.org/firefox-kde-opensuse/

Mountain 03-15-2012 01:03 PM

It appears that the firefox-kde-support package is broken right this moment. We're hoping it gets fixed in time for the Kubuntu 12.04 release. Here's the bug report: https://bugs.launchpad.net/ubuntu/+s...er/+bug/949949

However, the xdg-open workaround mentioned by cendryon is a very good solution. It may even be the best way of doing it. Here are the steps from Canonical support:
Quote:

1) stop firefox
2) rm ~/.mozilla/firefox/<profile>/mimeTypes.rdf
3) start firefox
4) download a file
5) open it from the downloads menu and choose the application. Browse to /usr/bin/xdg-open. then check to remember your choice

Now both open and open containing folder should work. You can then change the preferred programs through kde's file associations settings.
It works great for me.


All times are GMT -5. The time now is 11:59 PM.