Skip navigation
top menu
  • user notice: The _custom_breadcrumbs_get_breadcrumb() function called token replacement with an array rather than a string for $text in /home/jeroenbudts/sites/budts.be/sites/all/modules/contrib/token/token.module on line 263.
  • user notice: The _custom_breadcrumbs_get_breadcrumb() function called token replacement with an array rather than a string for $text in /home/jeroenbudts/sites/budts.be/sites/all/modules/contrib/token/token.module on line 263.
  • user notice: The _custom_breadcrumbs_get_breadcrumb() function called token replacement with an array rather than a string for $text in /home/jeroenbudts/sites/budts.be/sites/all/modules/contrib/token/token.module on line 263.
  • user notice: The _custom_breadcrumbs_get_breadcrumb() function called token replacement with an array rather than a string for $text in /home/jeroenbudts/sites/budts.be/sites/all/modules/contrib/token/token.module on line 263.

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

Hardik's picture

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....

Stephan Sokolow's picture

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)

Post new comment
The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options