LWN.net Logo

My personal paper cut

My personal paper cut

Posted Jul 24, 2009 16:30 UTC (Fri) by cortana (subscriber, #24596)
In reply to: My personal paper cut by jimparis
Parent article: Fighting small bugs

Having to send a file browser to /usr/bin to find an executable to handle a file type is insane. There are 3240 files in that directory on my system. How a non-expert user is supposed to cope is beyond me--if they don't give up after Firefox 'crashes' (freezes while stat'ing all the files in there) first.

Compare with the user experience in Epiphany, which actually makes an effort to integrate with the GNOME desktop; the user is presented with the option to open the file with their default handler, or save it to disk. The default handler is determined via the freedesktop.org MIME spec, which is the same thing used by everything else in GNOME. An administrator may change that for a particular user, or all users, using the standard Unixoid methods outlined in the spec.

Where Epiphany falls down is in letting the user change their preferred handler for a file type; there is no UI for that yet. So the user would have to save the file, then change the handler for it in Nautilus. Eventually, hopefully Epiphany will be enhanced to ask the MIME database who could handle the MIME type it's been served, and give the user a nice list of all the programs that can handle it, in the same way that Nautilus does. Nothing's perfect, eh? :)


(Log in to post comments)

My personal paper cut

Posted Jul 24, 2009 16:49 UTC (Fri) by jimparis (subscriber, #38647) [Link]

Forgive me if I'm dense, but I'm still not seeing what Firefox is doing wrong here. As far as I can tell, it's following the exact same method as everyone else -- it uses /etc/mime.types to map mime-types to file extensions, and it uses /etc/mailcap and ~/.mailcap to choose a default application. If you want to change the default application, then that's the only time you need to open up the file browser -- and I rarely use it to actually browse /usr/bin, I just type the desired executable name directly.

(Incidentally, the Freedesktop.org spec only seems to cover mime types, not mailcap. I don't see which of their specs covers default applications?)

My personal paper cut

Posted Jul 24, 2009 16:52 UTC (Fri) by jimparis (subscriber, #38647) [Link]

By the way, that's not to say Firefox can't use improvements in this area. For example, bug https://bugzilla.mozilla.org/show_bug.cgi?id=83305 has been an occasional issue for me for many years now -- with upstream's response being basically "blah, I can't be bothered to fix this". One of these days I'll be motivated to fix it myself, but my brief glances into the Firefox code always scare me...

My personal paper cut

Posted Jul 24, 2009 23:06 UTC (Fri) by cortana (subscriber, #24596) [Link]

The problem is that you are an expert, whereas most users--for instance, my parents are not. :)

They will be presented with a file selection dialog box and have no idea that they are supposed to go to /usr/bin, and then wait for Firefox to unfreeze, and then pick one of thousands of similarly named items that have absolutely no connection with what they want to do.

For example, opening a PDF document... how is a normal person supposed to know to select evince? :(

As for the freedesktop.org spec... I actually mis-spoke (typed?) earlier. The spec I mentioned allows programs to declare MIME types (that is, provide a mapping from MIME type to human-readable description). It serves a similar purpose to /etc/mime.types, except that it is more modular (it allows applications to define new MIME types) and it allows for the MIME types to have human-readable descriptions, localized to many different languages.

The spec I should have mentioned is the Desktop Entry spec; this is where applications ship .desktop files (in /usr/share/desktop and other places) that specify (among other things) which MIME types an application may handle. It is similar in purpose to the mailcap mechanism, but again it is more modular and allows internationalization, as well as desktop integration (e.g., application menu entries are derived from the .desktop files).

So, Firefox should be reading these .desktop files and offering the user's default handler for a file, along with a selection of other applications that declare that they handle the MIME type. On my system:

$ grep application/pdf /usr/share/applications/mimeinfo.cache
application/pdf=evince.desktop;gimp.desktop;

My personal paper cut

Posted Jul 24, 2009 20:50 UTC (Fri) by nix (subscriber, #2304) [Link]

Whatever FF is doing that makes it freeze, it's not statting:

nix@hades 40 /home/nix% /usr/bin/time stat /usr/bin/* >/dev/null
0.21user 0.14system 0:00.78elapsed 46%CPU (0avgtext+0avgdata
0maxresident)k
0inputs+0outputs (1major+335minor)pagefaults 0swaps

Maybe it's running file(1) or libmagic on every single one? That could
look like a freeze if you didn't notice the disk pounding away:

nix@hades 41 /home/nix% /usr/bin/time file /usr/bin/* >/dev/null
0.17user 0.58system 0:26.16elapsed 2%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (0major+735minor)pagefaults 0swaps

(This is on a system with 3977 binaries in /usr/bin.)

My personal paper cut

Posted Jul 24, 2009 21:18 UTC (Fri) by jimparis (subscriber, #38647) [Link]

> (This is on a system with 3977 binaries in /usr/bin.)

Now it's a challenge :)

$ ls /usr/bin | wc -l
2660
$ ssh psy ls /usr/bin | wc -l
3180
$ ssh bucket ls /usr/bin | wc -l
2221
$ ssh neurosis ls /usr/bin | wc -l
2605
$ ssh oldneurosis ls /usr/bin | wc -l
4036

Finally!

My personal paper cut

Posted Jul 24, 2009 22:08 UTC (Fri) by nix (subscriber, #2304) [Link]

Aha. I just installed KDE4 on that machine (in parallel with KDE3, OK,
yes, I'm reaching):

nix@hades 3 /home/nix% ls -l /usr/bin | wc -l
4102

:)

(is this the single most pointless contest that has ever been carried out
on LWN? I bet I have more symlinks in /usr/bin than you: 4099...)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds