[SOLVED] xdg-open $PWD opens directory in firefox, so does every qt app
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
xdg-open $PWD opens directory in firefox, so does every qt app
Good day fellow slackers,
I have this problem for quite a while now, but patiently tried to look for a cure myself. However, I was unlucky, so I'm asking for help.
My systems:
2 computers running Slackware64 14.0 multilib enabled, without KDE, Or Xfce, but with Mate 1.6 from MSB installed.
The problem:
Skype, Dropbox and possibly other qt programs always opens directory (where downloaded files are) in Firefox. GTK programs, shows them in caja however.
What I suspect, is misbehaving xdg-open, because, if I try to open directories directly form a command line using xdg-open:
Code:
xdg-open $PWD
Or:
xdg-open file:///home
directories opens in firefox.
I have tried to add application/x-directory=caja-folder-handler.desktop; and inode/directory=caja-folder-handler.desktop to my .local/share/applications/mimeapps.list but no effect.
and then I have used xdg-mime command to set default programs:
Code:
xdg-mime default caja-folder-handler.desktop inode/directory
and
xdg-mime default caja-folder-handler.desktop application/x-directory
without success.
I have also tried to remove my .local/share/mime and .local/share/applications so the system would create new ones, but that did not work aether.
I have tried to search for a solution online, but ended up banging my head onto the wall, which did not help too
In Archforums, there was a solution to install perl-file-mimeinfo, but there is no such package for Slack. And other solution was to export DE=xfce in .xinitrc but that did not help.
So I thought I should ask here, hopefully someone had similar problems in the past.
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
Code:
$GNOME_DESKTOP_SESSION_ID
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:
Code:
# Checks for known desktop environments
# set variable DE to the desktop environments name, lowercase
detectDE()
{
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;
else DE=""
fi
}
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!
Probably most "Clean" solution would be Mate's own section in xdg-open. Hopefully this will happen in time. Otherwise MSB mate is very reliable and dependable DE
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.