xdg-open vs exo-open

While playing with XFCE (more on that later) I was searching for a tool equal to gnome-open. Gnome-open can be used under Gnome to open files etc in the preferred application. While Googling I found not one, but two tools in various blogposts and forum messages: xdg-open and exo-open. I tried both, and both did the trick.

So that left me wondering: what's the difference after the two? Googling didn't really give a useful answer.

Yesterday I found the answer, by accident: exo-open is the tool from XFCE to open files etc in your preferred application, similar to gnome-open, under Gnome, and kde-open under KDE. xdg-open is a shell-script which works independent from the desktop-environment. It will inspect your environment and if it can detect that you are running Gnome, KDE, XFCE or LXDE it will use the correct tool from your Desktop Environment (such as exo-open under XFCE). If it can't detect your environment it will try to open the file itself. So basically, if you know which Desktop Environment you are running, you can use the tools which comes with your DE. If you're uncertain, or you are writing a script which should work across different Desktop Environments, use xdg-open. Or simply always use xdg-open.

Comments

Avatar

Hardik on 2011-09-14 08:15 reply

xdg-open tries to open.pdf file in the browser

Hi,

I am using xdg-open ,
so when the program runs and i tried to open that FileName.pdf using my application tries to open that file in the default browser say Firefox,rather than the Default Viewer for the .pdf files.

Any Help....

Avatar

Stephan Sokolow on 2011-12-22 10:48 reply

Re: xdg-open tries to open.pdf file in the browser

Hardik, when xdg-open doesn't detect a KDE/GNOME/Xfce/LXDE session, it's quite stupid.

 

If you have any shell scripting experience at all, my advice would be to run sh -x $(which xdg-open) FileName.pdf to see how it's deciding to use your browser.

 

For example, on my emergency machine's Lubuntu desktop, it ignores my preference for Chromium and opens URLs in Firefox because the session name is "Lubuntu" and "Lubuntu" != "LXDE" and the generic lookup for URLs ignores ~/.local/share/applications/mimeapps.list in favor of $BROWSER (which can't be set to xdg-open and will default to preferring Firefox over Chromium if unset)

Avatar

Matthew on 2012-07-13 06:50 reply

I had this problem. sh -x was

I had this problem. sh -x was helpful, and I found that xdg-open needs xprop, which wasn't available on my machine.

Comment Atom Feed