Xfce/Gnu/Linux works amazingly well on my moms workstation, with one exception: opening files automatically with the correct program.
The two biggest culprits are:
Luckily the fd.o guys have come up with .desktop files.
::Read from here
In $XDG_DATA_HOME/applications/defaults.list you can define which applications to use for which mime type.
So the only thing you need to do is call xdg-open to open a file with the application you want.
And that's exactly what I did. For now I just configure everything to use xdg-open and that seems to work just fine. Oddly enough, even though the defaults.list is also based on mimetypes, files that are marked as octet-stream in Thunderbird seem to be properly recognized by xdg-open and opened with the correct program. Or maybe this is because at the time of testing I only had octet-stream .doc files. Anyway, we'll see. But for now it's looking pretty good.
Note: somewhat related and also not very pleasant: epdfview used to say 'encrypted document.. please enter password' whenever you tried to open a non-existent file, a directory,.. basically anything else then a pdf file. But this seems to be fixed since 5 days ago.
This is a useful bit of info, I have been annoyed by this quite a few times.
In my personal experience, Firefox was never able to download and open a pdf file, It would give me that encrypted document thing every time. Eventually I switched to evince over epdfview (seems to render slightly faster for some reason), but I still had to use mozplugger for it to work. Recently when mozplugger was interfering with the gecko-mediaplayer plugin I got rid of it, and noticed that now Firefox does what it's supposed to.
Posted by Nick on Tue Sep 22 16:34:31 2009
The goofy thing about this is that it requires desktop files in some global directory to work. I can't tell it to run ~/bin/myscript easily, can I?
Posted by Aaron Griffin on Tue Sep 22 17:21:29 2009
Well, no, the .desktop files used can also be in $XDG_DATA_HOME/share/applications/ ...
Posted by Samuel Dionne-Riel on Tue Sep 22 18:05:39 2009
Nice find! This is functionality that I've been missing for a while.
I'm going to try to roll this out onto my machines over the next week - might post again about my experiences
Posted by jim on Tue Sep 22 18:13:04 2009
I didn't notice when it happened, but for a while now everything I try to open in Xarchiver, is opened by Firefox and then Firefox asks if I want to open the file with my preferred application for that file type. Xarchiver uses xdg-open.
For example, I have this line in defaults.list: "application/pdf=evince.desktop" but if I make "xdg-open /path/to/pdf.file" the pdf is opened by Firefox that asks if I want to open the file with evince :-/. Any idea why this happens?
PS: I know there's a file where I have a lot of mimetypes <-> application association, this file is read by Firefox. But I don't remember where it is and don't know I useful is this.
Posted by André on Tue Sep 22 19:21:36 2009
- Aaron/Samuel: you can indeed have both global and user-specific .desktop files. (AFAIK all fd.o specs are configurable globally and per-user, where relevant). So you can easily run your own scripts too.
- Jim: please do
- Andre: that's odd. You can use xdg-mime to debug this.
I believe there are some mime related config files in $XDG_CONFIG_HOME or $XDG_DATA_HOME.
Posted by Dieter_be on Wed Sep 23 06:42:52 2009
Ok, so I was missing the "xprop" command contained in the xorg-utils package. The most interesting part is that after I installed it, xdg-open started to work has I expected but it broke xdg-mime that now always returns the message "xdg-mime: no method available for quering MIME type of 'file name here'".
Posted by Andre on Wed Sep 23 10:33:55 2009
xdg-open is fine most times, but it always backgrounds the process. That is, if you type "xdg-open filename" in bash, it immediately returns to the prompt and the opener runs in the background.
However some application wait until the opener has finished and then delete that file (e.g. alpine). In that case xdg-open is useless because the file is deleted by the time the opener tries to open it.... Any ideas for that?
Posted by jimis on Thu Sep 24 11:31:22 2009
Ugh I just looked at xdg-open's source code (it's just sh) and it's looking uglier then I thought.
It tries to detect your DE (kde/gnome/xfce) and falls back to "generic" if none found. It has branches to do different things depending on your DE.
kde -> kfmclient
gnome -> gnome-open
Xfce -> exo-open
In my case it's 'generic' so it just executes the command and waits for it. In the other cases it will wait for exo-open/gnome-open/.. to return, and returns it's exit code.
So I guess in your case the problem is exo-open/gnome-open/.. returning too fast. I don't have any of those tools so I can't help. (any time is a good time to switch to a lightweight tiling WM ;-)
Posted by Dieter_be on Fri Sep 25 11:21:23 2009
Sorry for the late reply.
It's not terrible to do this, just need to create a myscript.desktop file and associate it with the mimetype. Find something simple in /usr/share/applications as a base and make one with your script as Exec, I belive %F is replaced by the filename.
I used to have one for a custom playnow script to pipe audio through mpd, but I stopped using xdg-open proper a while ago. It's way easier (IMO) to just mask it by putting my own xdg-open script ahead of the default in $PATH, then I have a simple case statement. Could even fall back on extension if I wanted to...
As long as Chromium/Firefox/etc is looking for an xdg-open in $PATH and yours is the first it finds, you can control the behavior however you want.
Posted by pbrisbin on Tue Nov 23 12:09:16 2010
Yeah I've also realised the xdg-open stuff is more complicated (and limited) then it should be.
A script like yours is an elegant solution.
There's also Xyne's mimeo which is pretty similar: http://xyne.archlinux.ca/projects/mimeo/
Posted by Dieter_be on Thu Nov 25 04:23:01 2010