LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 12-19-2017, 10:33 AM   #1
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Wrong application for opening directories with xdg-open


Background: I'm using udiskie for automatic mounting of devices with a window manager. It is working well, except that when I try to browse a mounted volume, it opens in Firefox instead of my default file browser (PCManFM). I looked in the source code for udiskie, and it appears to use xdg-open for browsing.

I have set xdg-mime to open directories with PCManFM:
Code:
dan@Thinkpad-T430:~$ xdg-mime default pcmanfm.desktop inode/directory
dan@Thinkpad-T430:~$ xdg-mime query default inode/directory
pcmanfm.desktop;
But when I try to open a directory with xdg-open, I get the following:
Code:
dan@Thinkpad-T430:~$ xdg-open ~
/usr/bin/xdg-open: line 781: x-www-browser: command not found
And then it proceeds to open the directory with Firefox. I can get around this by setting the BROWSER environment variable to pcmanfm, but why is it attempting to open directories with Firefox in the first place, if I have pcmanfm set as the default for inode/directory?

Note: I have also tried using different file managers instead of PCManFM, but the behavior is the same no matter what.
 
Old 12-19-2017, 10:39 AM   #2
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
I found this in the xdg-open manpage:

Quote:
xdg-open opens a file or URL in the user's preferred application. If a URL is provided the URL will be opened in the user's preferred web browser. If a file is provided the file will be opened in the preferred application for files of that type.
So the problem seems to be that it interprets directories as URLs. Perhaps setting the default application for inode/directory is not the proper way to fix this, but I'm not sure what the proper way is.
 
Old 12-19-2017, 10:46 AM   #3
imitis
Member
 
Registered: Oct 2007
Location: Latvia, Liepaja
Distribution: Slackware
Posts: 92

Rep: Reputation: 29
I had the same problem. solved it with xfce mime editor. set default application for inode/directory to thunar and it works.
 
Old 12-19-2017, 11:23 AM   #4
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
I will give that a try when I get home and can install XFCE, but surely there must be a way to make this work without installing a new DE. After all, the whole point of using a window manager is that I don't want to use a DE.
 
Old 12-19-2017, 11:37 AM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Use xdg-mime to set the default application for inode/directory, IIRC.

https://bbs.archlinux.org/viewtopic....23972#p1223972

EDIT: I'll leave this up, but I can see now that you've already addressed this in the first post.
 
Old 12-19-2017, 12:22 PM   #6
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
I did some testing on the KDE side, and everything worked as expected. I then went back to the window manager (awesome) and set:

Code:
export XDG_CURRENT_DESKTOP=KDE
and then it worked. However, I'd rather not do that if possible, because then it must run kdeinit5 first, which seems unnecessary. I don't want to be dependent on KDE just to get XDG mime associations working correctly.
 
Old 12-19-2017, 02:29 PM   #7
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
So, the problem seems to be the semicolon after pcmanfm in the xdg-mime query output:

Code:
dan@Thinkpad-T430:~$ xdg-mime query default inode/directory
pcmanfm.desktop;
If I hard-code the desktop file in xdg-open like this:

Code:
open_generic_xdg_mime()
{
    filetype="$2"
-   default=`xdg-mime query default "$filetype"`
+   default="pcmanfm.desktop"
    if [ -n "$default" ] ; then
        xdg_user_dir="$XDG_DATA_HOME"
        [ -n "$xdg_user_dir" ] || xdg_user_dir="$HOME/.local/share"

        xdg_system_dirs="$XDG_DATA_DIRS"
        [ -n "$xdg_system_dirs" ] || xdg_system_dirs=/usr/local/share/:/usr/share/

DEBUG 3 "$xdg_user_dir:$xdg_system_dirs"
        for x in `echo "$xdg_user_dir:$xdg_system_dirs" | sed 's/:/ /g'`; do
            search_desktop_file "$default" "$x/applications/" "$1"
        done
    fi
}
then it works even without XDG_CURRENT_DESKTOP set to KDE. So the question is now, is the problem with the semicolon being present in the xdg-mime query output, or is it with how xdg-open parses it? FWIW, I tried manually editing ~/.local/share/applications/mimeapps.list to add or remove the semicolon, and it didn't make a difference.
 
Old 12-19-2017, 02:43 PM   #8
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
You can see all the default applications in ~/.local/share/applications/ in mimeapps.list and defaults.list.

That's where xdg gets its info from.
 
Old 12-19-2017, 02:44 PM   #9
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Woops. Double-post.

Last edited by dive; 12-19-2017 at 02:45 PM.
 
Old 12-19-2017, 05:27 PM   #10
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Quote:
Originally Posted by dive View Post
You can see all the default applications in ~/.local/share/applications/ in mimeapps.list and defaults.list.

That's where xdg gets its info from.
I'm going to have to look at the xdg-mime source code now, because this is getting confusing. When I was testing on KDE, I set the default for inode/directory to Dolphin though KDE system settings. Now I reset it to PCManFM with `xdg-mime default pcmanfm.desktop inode/directory`. There is no ~/.local/share/applications/defaults.list, but mimeapps.list shows pcmanfm.desktop as the default. However, `xdg-mime query default inode/directory` still outputs "org.kde.dolphin.desktop;", even after rebooting. So where could it be getting that from?

Last edited by montagdude; 12-19-2017 at 05:28 PM.
 
Old 12-19-2017, 05:35 PM   #11
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
Well there is also /usr/share/applications but doing a locate org.kde.dolphin.desktop doesn't show anything. I would guess that it's querying kde system settings somehow.
 
Old 12-19-2017, 07:51 PM   #12
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
Apparently, it was finding ~/.config/mimeapps.list, which must be the file the KDE uses. That file had a whole list of applications for inode/directory, separated by semicolons. xdg-mime doesn't handle this correctly, apparently.

Code:
dan@Thinkpad-T430:~$ export XDG_UTILS_DEBUG_LEVEL=3
dan@Thinkpad-T430:~$ xdg-mime query default inode/directory
Checking /home/dan/.config/mimeapps.list
org.kde.dolphin.desktop;
The XDG_UTILS_DEBUG_LEVEL environment variable causes xdg programs to print more info, which showed that it was checking /home/dan/.config/mimeapps.list. To fix it, I did this:

Code:
dan@Thinkpad-T430:~$ mv ~/.config/mimeapps.list ~/.config/mimeapps.list.bkp
dan@Thinkpad-T430:~$ xdg-mime default pcmanfm.desktop inode/directory
make_default_kde: No kde runtime detected
make_default_generic pcmanfm.desktop inode/directory
Updating /home/dan/.local/share/applications/mimeapps.list
dan@Thinkpad-T430:~$ xdg-open ~
Selected DE generic
Running file --brief --dereference --mime-type "/home/dan"
Checking /home/dan/.local/share/applications/mimeapps.list
/home/dan/.local/share:/usr/local/share/:/usr/share/
And now it works.

EDIT: In case that's not clear, the fix was to rename ~/.config/mimeapps.list to ~/.config/mimeapps.list.bkp and then run `xdg-mime default pcmanfm.desktop inode/directory`.

Last edited by montagdude; 12-19-2017 at 08:13 PM.
 
2 members found this post helpful.
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] xdg-open: no method available for opening Amdx2_x64 Programming 3 12-13-2017 11:00 PM
Customizing xdg-open on a per-application basis mgillen2000 Linux - Desktop 1 02-10-2017 04:00 PM
[SOLVED] using openbox as bare WM : setting xdg default application to okular fails jtwdyp Linux - Desktop 3 01-28-2016 02:13 PM
[SOLVED] How do I get xdg-open (and Chromium) to open FLV files in mpv? dugan Slackware 2 08-15-2015 04:51 PM
xdg-open crashes when I try to open something with it (Segmentation fault) Vexe VectorLinux 1 02-11-2013 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:01 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration