Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 220915 - x11-misc/xdg-utils: `xdg-open` only supports "major" Desktop Environments
Summary: x11-misc/xdg-utils: `xdg-open` only supports "major" Desktop Environments
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Freedesktop bugs
URL:
Whiteboard:
Keywords:
: 252638 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-05-08 12:16 UTC by Ralf Treu
Modified: 2011-04-26 07:29 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch as own file (xdg-open.1.0.2.patch,299 bytes, patch)
2008-05-08 19:47 UTC, Ralf Treu
Details | Diff
xdg-utils-1.0.2_p20100618.ebuild.patch (xdg-utils-1.0.2_p20100618.ebuild.patch,1.02 KB, patch)
2010-09-03 09:25 UTC, Jan Pobrislo
Details | Diff
xdg-utils-1.0.2_p20100618-mailcap.patch (xdg-utils-1.0.2_p20100618-mailcap.patch,578 bytes, patch)
2010-09-03 09:26 UTC, Jan Pobrislo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Treu 2008-05-08 12:16:14 UTC
When using tracker-search-applet or beagle in window managers like fluxbox those tools use xdg-open to open indexed files with the proper application. xdg-open only supports gnome-/kde-/xfce-open and therefor trys to open every file in a browser when it realizes that gnome-/kde-/xfce-open are not there.


Reproducible: Always

Steps to Reproduce:
1. Install a *-box or any other WM and the rox-filer, unmerge gnome/kde/xfce
2. Install tracker / tracher-search-applet
3. open tracker-search-applet in that wm and search for some files.
4. Try to open those files directly from tracker-search-applet or try to open them directly with xdg-open.

Actual Results:  
Files opened by tracker-search-applet or by xdg-open in genereal will always be displayed in a browser.

Expected Results:  
Rox could have opened the file with the user's preferred application.

My patch for xdg-open-1.0.2 to support rox:

306a307
>     elif [ -e $HOME/.config/rox.sourceforge.net ]; then DE=rox;
360a362,373
> open_rox()
> {
>     rox "$1"
> 
>     if [ $? -eq 0 ]; then
>         exit_success
>     else
>         exit_failure_operation_failed
>     fi
> }
> 
> 
428a442,445
>     rox)
>     open_rox "$url"
>     ;;
>
Comment 1 Daniel Gryniewicz (RETIRED) gentoo-dev 2008-05-08 19:25:15 UTC
This should probably be submitted upstream.  Others can benifit from it too.
Comment 2 Ingmar Vanhassel (RETIRED) gentoo-dev 2008-05-08 19:41:19 UTC
Also, attach patches (diff -u) instead of pasting them inline, please.
Comment 3 Ralf Treu 2008-05-08 19:47:06 UTC
Created attachment 152513 [details, diff]
patch as own file
Comment 4 Ralf Treu 2008-05-08 19:48:34 UTC
(In reply to comment #1)
> This should probably be submitted upstream.  Others can benifit from it too.
> 
I already sent it to Portland mailing list but got no answer. Hope one of the gentoo officials can submit it upstream and get an answer.
Comment 5 Gilles Dartiguelongue (RETIRED) gentoo-dev 2009-03-07 11:57:06 UTC
*** Bug 252638 has been marked as a duplicate of this bug. ***
Comment 6 Anatoly Yakovenko 2009-09-02 21:37:39 UTC
I ran into this issue with google-chrome, it kept opening firefox for everything.  I got this to work on non DE desktop.  

change xdg-open open_generic function to this:
open_generic()
{
   mimetype=`xdg-mime query filetype "$url"`
   opener=`xdg-mime query default $mimetype | xargs cat | grep Exec | cut -f 2 -d =`
   if [ -z "${opener}" ] ; then
      exit_failure_operation_impossible "no method available for opening '$url'"
   fi
   "$opener" "$url"
}

and add this script to add handlers for non DE desktops

$ cat ./xdg-add-handler
#!/bin/bash
mimetype=`xdg-mime query filetype $2` 
name=$1
opener=`which $name`

exit_failure_operation_impossible()
{
    if [ $# -gt 0 ]; then
        echo "xdg-add-handler: $@" >&2
    fi

    exit 3
}


if [ -z "${opener}" ] ; then
      exit_failure_operation_impossible "no binary for name '$name'"
fi

if [ -z "${mimetype}" ] ; then
      exit_failure_operation_impossible "no mimetype for file '$2'"
fi
mkdir -p ~/.local/share/applications
echo "[Desktop Entry]
Exec=$opener
MimeType=$mimetype;
Name=$name
NoDisplay=true
Type=Application" > ~/.local/share/applications/$name.desktop
xdg-mime default ~/.local/share/applications/$name.desktop $mimetype
Comment 7 Jan Pobrislo 2010-09-03 09:23:46 UTC
Also xdg-open only supports run-mailcap on debian systems (the script is pretty messed up imho).
app-misc/run-mailcap is pretty safe default when no specific DE is running, (better than trying every browser it knows, which is what it does now), so I suggest pulling it as dependency by default.

I created edited ebuild and patch for xdg-open, which pulls app-misc/run-mailcap on mime use-flag.
Comment 8 Jan Pobrislo 2010-09-03 09:25:36 UTC
Created attachment 245841 [details, diff]
xdg-utils-1.0.2_p20100618.ebuild.patch

patch xdg-open to allow run-mailcap and +mime use flag
Comment 9 Jan Pobrislo 2010-09-03 09:26:36 UTC
Created attachment 245842 [details, diff]
xdg-utils-1.0.2_p20100618-mailcap.patch

patch for the xdg-utils-1.0.2_p20100618.ebuild.patch
Comment 10 Samuli Suominen (RETIRED) gentoo-dev 2010-09-03 09:44:42 UTC
This needs to be reported upstream. 
For the foreseen future, the maintaince of this package is creating snapshots from upstream version control, that's it.
Comment 11 Rick Leijssen 2010-09-09 15:05:59 UTC
Actually, it does (also) have a fallback to mimeopen, which is provided in the dev-perl/File-MimeInfo package in portage. 

I only found out about this because someone mentioned this in a comment on a support ticket for mendeleydesktop, which uses xdg-open to open pdf files externally. I also found an extensive discussion on the LyX mailing list on this same issue (http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg133878.html starts the thread) which has a reference to the bugreport that included the mimeopen support (https://bugs.freedesktop.org/show_bug.cgi?id=13953). By the way, this issue apparently also occurs when using xdg-open over X-forwarding ssh, see https://bugs.freedesktop.org/show_bug.cgi?id=9822.

I actually came here to complain about the fact that the File-MimeInfo package is listed as an (optional) dependency for this package. Even after finding out the script also calls "mimeopen", it cost me some time to find out which package provides this program. 
Comment 12 Rick Leijssen 2010-09-09 15:08:46 UTC
(In reply to comment #11)
> I actually came here to complain about the fact that the File-MimeInfo package
> is listed as an (optional) dependency for this package. Even after finding out
> the script also calls "mimeopen", it cost me some time to find out which
> package provides this program. 
> 

Re-reading my own comment, this sounds a bit harsh. I meant "complain" in a ironic way, but text-only is not a good medium to convey that. Please don't take my comment as criticism, I only wanted to point out something that I found was missing in my user experience :)
Comment 13 Samuli Suominen (RETIRED) gentoo-dev 2011-02-14 11:52:54 UTC
This should be now solved by xdg-utils-1.1.0_rc1-r1 ( which includes fix for https://bugs.freedesktop.org/show_bug.cgi?id=13953 )
Comment 14 Tom Gillespie 2011-03-30 17:15:54 UTC
This problem still seems to exist in xdg-utils 1.1.0_rc1_p20110329. When running fluxbox the behavior with chromium-browser remains the same (tries to open all files in firefox). If this is a different problem from the one in this thread then I would happily open a new bug.
Comment 15 Samuli Suominen (RETIRED) gentoo-dev 2011-03-30 17:24:17 UTC
that's different bug. 

the browser needs to have x-scheme-handler/http; and x-scheme-handler/https; in it's .desktop file to get recognized as a real browser.
Comment 16 Samuli Suominen (RETIRED) gentoo-dev 2011-03-30 17:28:01 UTC
(In reply to comment #15)
> that's different bug. 
> 
> the browser needs to have x-scheme-handler/http; and x-scheme-handler/https; in
> it's .desktop file to get recognized as a real browser.

and then you could (or should?) have ~/.local/share/applications/mimeapps.list

replace foobar with yours...

[Added Associations]
x-scheme-handler/http=foobar.desktop
x-scheme-handler/https=foobar.desktop

and the file could continue like... for some older types...

application/x-extension-htm=foobar.desktop;
application/x-extension-html=foobar.desktop;
application/x-extension-shtml=foobar.desktop;
application/xhtml+xml=foobar.desktop;
application/x-extension-xhtml=foobar.desktop;
application/x-extension-xht=foobar.desktop;

[Default Applications]
text/html=foobar.desktop
application/x-extension-htm=foobar.desktop
application/x-extension-html=foobar.desktop
application/x-extension-shtml=foobar.desktop
application/xhtml+xml=foobar.desktop
application/x-extension-xhtml=foobar.desktop
application/x-extension-xht=foobar.desktop
Comment 17 Samuli Suominen (RETIRED) gentoo-dev 2011-03-30 17:28:30 UTC
(In reply to comment #15)
> that's different bug. 
> 
> the browser needs to have x-scheme-handler/http; and x-scheme-handler/https; in
> it's .desktop file to get recognized as a real browser.

and if it's missing, it's a bug in said browser
Comment 18 Leho Kraav (:macmaN @lkraav) 2011-04-24 18:22:01 UTC
(In reply to comment #14)
> This problem still seems to exist in xdg-utils 1.1.0_rc1_p20110329. When
> running fluxbox the behavior with chromium-browser remains the same (tries to
> open all files in firefox). If this is a different problem from the one in this
> thread then I would happily open a new bug.

is this a good place to ask why:

$ xdg-open --version
xdg-open 1.1.0 rc1

530         BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER

doesn't include firefox-bin, at least as a gentoo patch?
Comment 19 Samuli Suominen (RETIRED) gentoo-dev 2011-04-26 07:20:35 UTC
(In reply to comment #18)
> (In reply to comment #14)
> > This problem still seems to exist in xdg-utils 1.1.0_rc1_p20110329. When
> > running fluxbox the behavior with chromium-browser remains the same (tries to
> > open all files in firefox). If this is a different problem from the one in this
> > thread then I would happily open a new bug.
> 
> is this a good place to ask why:
> 
> $ xdg-open --version
> xdg-open 1.1.0 rc1
> 
> 530        
> BROWSER=firefox:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
> 
> doesn't include firefox-bin, at least as a gentoo patch?

The firefox-bin package has different command for running firefox? Intresting.

But ...

Note that the hardcoded list isn't used at all if you have properly setupped the default browser like sain in Comment #16, the dev-perl/File-MimeInfo depend was added for that, it should read the mime and get the browser from there, even firefox-bin.

So the hardcoded list is only a fallback list, but feel free to open a new bug for it anyway
Comment 20 Leho Kraav (:macmaN @lkraav) 2011-04-26 07:29:59 UTC
bug 364891