[SOLVED] xdg-open $PWD opens directory in firefox, so does every qt app
SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have just compared one of my systems, to another simmilar system, but with Xfce instead of mate, and there xdg-open $PWD and other applications does open directory in Thunar. But that system does not have any entry about inode/directory or application/x-directory in mimeapps.list. I am starting to think, that xdg-open script it self might not recognize caja, as a file browser. And in case I do not have any other file manager (dolphin, thunar, nautilus) it thinks of firefox as a last resort.
Now, xdg-open is quite complicated to me, so it would be nice if someone more capable would take a look
/usr/bin/xdg-open (it is just a shell script) checks to see if you're running a well-known desktop environment (KDE, Gnome, XFCE, or LXDE) and if identified tries to open it using the desktop environment's tools. XFCE is properly identified so it tries using exo-open to open files. Apparently when running MATE it is having difficulty detecting that you are running a Gnome equivalent. I assume MATE uses gvfs-open (which is actually installed by default on Slackware anyway), but if it is falling back to Firefox then it isn't trying gvfs-open at all. It attempts to detect a Gnome session by checking the value of
which I believe is deprecated (though I don't use MATE/Gnome so I could be wrong), so it is empty. Then it tries this:
I don't know anything about MATE but I would guess that perhaps this dbus stuff has been tweaked to specify mate instead of gnome and it is therefore failing. If you can find the proper dbus line to use, you could modify /usr/bin/xdg-open to use that line instead to properly detect MATE.
If you want to forgo gvfs-open and just use the default behaviour of xdg-open, then you will have to specify at least some mime types using xdg-mime, as you have tried to do. However, it does matter where the .desktop file resides. xdg-open checks the following directories for .desktop files:
If caja-folder-handler.desktop resides in a subdirectory, xdg-open will not find it (for example, dolphin.desktop is located in /usr/share/applications/kde4/dolphin.desktop -- therefore, if you specify dolphin.desktop as the default mime type for directories, it will not work with xdg-open's generic methods). If your .desktop file is in a subdirectory then I would advise copying (or symlinking) it to $HOME/.local/share/applications.
Using the same syntax you did, I was able to specify Thunar to open directories from a generic window manager, but not dolphin (due to the subdirectory issue -- though after symlinking it to $HOME/.local/share/applications it did work). xdg-mime will not give you an error if you specify an unknown .desktop file so you would have to do any checks manually.
The only other reason I can think of that it would fail is if the .desktop file is in $HOME/.local/share/applications but the XDG_DATA_HOME variable is set to something else, so you should make sure that is unset as well.
Thank you very much, T3slider. The problem indeed was in xdg-open failing to detect mate as gnome variant. Mate indeed uses gvfs-open. So I did a little, but dirty modification to xdg-open script:
# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase
if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde;
elif [ x"$DESKTOP_SESSION" != x"MATE" ]; then DE=gnome;
elif `dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager > /dev/null 2>&1` ; then DE=gnome;
elif xprop -root _DT_SAVE_MODE 2> /dev/null | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce;
elif [ x"$DESKTOP_SESSION" == x"LXDE" ]; then DE=lxde;
Basically, just modified $GNOME_DESKTOP_SESSION_ID to $DESKTOP_SESSION and replaced GNOME with MATE, so it detects Mate as gnome, there for uses gvfs-open. So far everything seems to work fine. Thanks again!
That check for MATE will always return true -- it is checking to see if $DESKTOP_SESSION does NOT equal MATE, which it won't in any desktop environment (obviously non-MATE DEs will not have DESKTOP_SESSION set to MATE, and MATE uses the lowercase mate instead). See here for a more elegant patch that would allow you to use gvfs in mate and maintain proper activity in other DEs/WMs. It appears this has been addressed upstream (see here and here) checking for MATE_DESKTOP_SESSION_ID, but Slackware-current hasn't upgraded xdg-utils from 14.0 so this will probably still be an issue in the next Slackware release (and it probably isn't important for Pat to update it considering Slackware does not ship MATE).
Every time I have to deal with xdg, I want to pull out my hair. How does one even design something like this?
I use openbox, and as it stands, xdg-open opens urls and html files with firefox, even though
(1) ~/.local/share/applications/mimeapps.list is configured to use icecat.desktop, which resides in ~/.local/share/applications.
(2) /usr/share/applications/defaults.list does not exist.
(3) xdg-mime query default text/html prints nothing.
kde-open, the only one which seems to obey its own settings, starts icecat (desired behavior).
gnome-open and gvfs-open seem to start whatever is written in /usr/share/applications/mimeinfo.cache (at least they are consistent).
exo-open starts seamonkey, even though I used xfce config tool to make icecat both the default browser and the default text/html handler. But this one I don't really care about, since I use no part of xfce.
So how the heck does xdg-open start firefox? And how can I change that? Can I make it obey ~/.local/share/applications/mimeapps.list? Setting $KDE_FULL_SESSION seems to do the trick, but is that a clean solution in the absence of KDE? I don't want anyone else to get confused by assuming that KDE is running.