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 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 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 :scratch: 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 :) |
fwiw, on my full Slackware-current system (so incl. dolphin, thunar) xdg-open $PWD also opens in firefox.
Not sure if using i3 (instead of KDE or Xfce) has something to do with it. |
/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 Code:
dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager 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: Code:
/usr/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 |
Thanks for this -- perhaps Willy and I need to incorporate this in MSB or at least mention it in the README.TXT.
|
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 :hattip:
|
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).
|
Cheers, just fixed my xdg-open with your mentioned elegant fix. Thank you again :hattip:
|
1 Attachment(s)
Just to put a bow on this and bring the above hints together -- here are the steps to get this working in MATE:
1. Apply the attached patch to /usr/bin/xdg-open. 2. Set your xdg-mime default handlers to caja (MATE's file manager): Code:
xdg-mime default caja-folder-handler.desktop inode/directory Thanks to Totoro-kun and T3slider! |
Thanks to Pat for incorporating the fix into -current that T3slider found. :-)
|
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. |
Quote:
|
Quote:
|
I agree. Xdg should be taken out behind the woodshed and dealt with. Severely.
|
Quote:
|
Hi,
While struggling with understanding of the weird xdg-open concepts I stumbled upon this post. I actually started to think if there is any mandatory need of having the xdg-utils installed on my machine? Will removing it cause some dependency problems? I noticed it is part of most major distributions these days. But is it really a necessity? thanks H. |
Quote:
Coordially, |
Well,
It might work for you, but for me a fresh install would mean a lot of reconfiguration and retweaking that would have to be done in order to bring the system to full usable state. That's why I prefer to ask before I get rid of something that is a part of some application or have some dependencies. As you correctly spotted you may not notice anything for the first couple of days/weeks and than you forget about it. Later on, after something crashes you wouldn't know what is the reason. And the reason might be the package you removed and forgot about... I use Slack as well. Regards |
Quote:
I was just wandering for a solution and this works perfectly. There was a huge chunk of code in DetectDE in my distro,I replaced it with your lines and It worked! Thanks a lot. |
All times are GMT -5. The time now is 08:47 AM. |