LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 06-09-2013, 06:43 AM   #1
Totoro-kun
Member
 
Registered: Nov 2010
Location: Kaunas, Lithuania
Distribution: Slackware
Posts: 160

Rep: Reputation: 44
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.
 
Old 06-09-2013, 12:21 PM   #2
Totoro-kun
Member
 
Registered: Nov 2010
Location: Kaunas, Lithuania
Distribution: Slackware
Posts: 160

Original Poster
Rep: Reputation: 44
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
 
Old 06-09-2013, 01:36 PM   #3
BroX
Member
 
Registered: Oct 2003
Location: Sweden
Distribution: Slackware64-current
Posts: 733

Rep: Reputation: 64
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.

Last edited by BroX; 06-09-2013 at 01:38 PM.
 
Old 06-09-2013, 02:05 PM   #4
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,231

Rep: Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573
/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:
Code:
dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.GetNameOwner string:org.gnome.SessionManager
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:
Code:
/usr/local/share/applications
/usr/share/applications
$HOME/.local/share/applications
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.
 
2 members found this post helpful.
Old 06-09-2013, 02:40 PM   #5
Totoro-kun
Member
 
Registered: Nov 2010
Location: Kaunas, Lithuania
Distribution: Slackware
Posts: 160

Original Poster
Rep: Reputation: 44
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!
 
1 members found this post helpful.
Old 06-09-2013, 02:57 PM   #6
chess
Member
 
Registered: Mar 2002
Location: 127.0.0.1
Distribution: Slackware, OpenBSD, FreeBSD
Posts: 728

Rep: Reputation: 168Reputation: 168
Thanks for this -- perhaps Willy and I need to incorporate this in MSB or at least mention it in the README.TXT.

Last edited by chess; 06-09-2013 at 02:58 PM.
 
Old 06-09-2013, 03:05 PM   #7
Totoro-kun
Member
 
Registered: Nov 2010
Location: Kaunas, Lithuania
Distribution: Slackware
Posts: 160

Original Poster
Rep: Reputation: 44
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
 
1 members found this post helpful.
Old 06-09-2013, 03:07 PM   #8
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,231

Rep: Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573Reputation: 573
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).
 
2 members found this post helpful.
Old 06-09-2013, 03:15 PM   #9
Totoro-kun
Member
 
Registered: Nov 2010
Location: Kaunas, Lithuania
Distribution: Slackware
Posts: 160

Original Poster
Rep: Reputation: 44
Cheers, just fixed my xdg-open with your mentioned elegant fix. Thank you again
 
Old 06-09-2013, 10:04 PM   #10
chess
Member
 
Registered: Mar 2002
Location: 127.0.0.1
Distribution: Slackware, OpenBSD, FreeBSD
Posts: 728

Rep: Reputation: 168Reputation: 168
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
xdg-mime default caja-folder-handler.desktop application/x-directory
3. Profit. :-)

Thanks to Totoro-kun and T3slider!
Attached Files
File Type: txt xdg-open.patch.txt (1.0 KB, 27 views)
 
2 members found this post helpful.
Old 06-10-2013, 07:39 PM   #11
chess
Member
 
Registered: Mar 2002
Location: 127.0.0.1
Distribution: Slackware, OpenBSD, FreeBSD
Posts: 728

Rep: Reputation: 168Reputation: 168
Thanks to Pat for incorporating the fix into -current that T3slider found. :-)
 
Old 09-26-2013, 08:31 PM   #12
qweasd
Member
 
Registered: May 2010
Posts: 432

Rep: Reputation: Disabled
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.
 
Old 09-26-2013, 08:37 PM   #13
volkerdi
Slackware Maintainer
 
Registered: Dec 2002
Location: Minnesota
Distribution: Slackware! :-)
Posts: 836

Rep: Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620Reputation: 1620
Quote:
Originally Posted by qweasd View Post
Every time I have to deal with xdg, I want to pull out my hair. How does one even design something like this?
Good question. Wish I had a good answer.
 
Old 09-27-2013, 10:23 AM   #14
qweasd
Member
 
Registered: May 2010
Posts: 432

Rep: Reputation: Disabled
Quote:
Originally Posted by qweasd View Post
So how the heck does xdg-open start firefox?
Bah, I got it. firefox is hard-coded into the script as the first browser to try if the configuration is missing.
 
Old 10-05-2013, 11:52 PM   #15
chess
Member
 
Registered: Mar 2002
Location: 127.0.0.1
Distribution: Slackware, OpenBSD, FreeBSD
Posts: 728

Rep: Reputation: 168Reputation: 168
I agree. Xdg should be taken out behind the woodshed and dealt with. Severely.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xdg-open crashes when I try to open something with it (Segmentation fault) Vexe VectorLinux 1 02-11-2013 11:38 AM
open list of files with xdg-open mahkoe Programming 1 02-03-2013 11:48 AM
xdg-open, gnome-open or kde(4?)-open??? akamikeym Programming 0 08-03-2010 08:54 AM
firefox dos not open when run under user (opens only in root) saso Mandriva 8 06-15-2005 10:07 AM
Unable to open firefox from evolution - always opens Mozilla tog Fedora 1 06-19-2004 12:01 PM


All times are GMT -5. The time now is 11:02 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration