You are not logged in.

#1 2009-11-15 18:31:46

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Best XDG Opener?

What is the best XDG Opener? (Like rox, exo-open (XFCE), gnome-open, mimeopen, kioclient)

Right now I'm using "rox", but I don't like how it comes with a file manager. I'd like to be able to have a seperate file manager and xdg opener, so I can pick and choose easily. Also rox can't open urls.


Libertarian Arch Linux User

Offline

#2 2009-11-15 20:15:34

Nezmer
Member
Registered: 2008-10-24
Posts: 559
Website

Re: Best XDG Opener?

xdg-open ?


English is not my native language .

Offline

#3 2009-11-15 20:35:47

RedArcher
Member
From: Palestine
Registered: 2009-09-03
Posts: 34

Re: Best XDG Opener?

@Nezmer
'xdg-mime'. please install GPicView (Community Repository)

Open GPicView (duh!)
Click on 'Preferences'
Then you'll see a button says "Make GPicview the default viewer for images"
Click on it and then a message will appear:
GPicView will become the default viewer for all supported image files on your system.
(This will be done through 'xdg-mime' program)

Are you sure you really want to do this?

I think that matthewbauer meant to this sort of stuff.

EDIT: never mind, forget what I just wrote =/

Last edited by RedArcher (2009-11-15 20:41:36)

Offline

#4 2009-11-15 22:51:00

matthewbauer
Member
From: /usa/ks
Registered: 2009-07-20
Posts: 86

Re: Best XDG Opener?

Well xdg-open by itself is only a link to another mime opener (cat /usr/bin/xdg-open). You need to have another application do the mime handling.


Libertarian Arch Linux User

Offline

#5 2009-11-15 23:04:20

Nezmer
Member
Registered: 2008-10-24
Posts: 559
Website

Re: Best XDG Opener?

You mean something like mimeman


English is not my native language .

Offline

#6 2009-11-16 00:36:59

radu242
Member
Registered: 2009-03-15
Posts: 11

Re: Best XDG Opener?

I just use this quick-n-dirty script. It queries xdg-mime for the correct application, except for the browser because xdg-mime doesn't seem to recognize web links. Although I haven't run into issues yet, the way it finds the executable is particularly hacky and doesn't respect any arguments in the Exec field of the .desktop file. But whatever, it works for me.

~ $ cat /usr/bin/xdg-open
#!/bin/bash

[ -z "$1" ] && exit 1

if echo "$1" | egrep -q "^(https?://|www.)"; then
    google-chrome "$1" # or whatever browser you choose
    exit
fi

desktop_file="$(xdg-mime query default $(xdg-mime query filetype "$1" | cut -d";" -f1))"

if [ -z "$desktop_file" ]; then
    exit 1
fi

function get_exec ()
{
    egrep "^Exec=" "$1" | cut -d"=" -f2 | sed -r "s:(%U|%f):$2:"
}

if [ -f "$HOME/.local/share/applications/$desktop_file" ]; then
    $(get_exec "$HOME/.local/share/applications/$desktop_file" "$1")
elif [ -f "/usr/share/applications/$desktop_file" ]; then
    $(get_exec "/usr/share/applications/$desktop_file" "$1")
else
    exit 1
fi

Offline

#7 2009-11-16 14:45:25

spupy
Member
Registered: 2009-08-12
Posts: 218

Re: Best XDG Opener?

xdg-open is the devil. Or maybe I don't understand it, because I can't make it use the right programs to open files. When I make it open folders with rox instead of firefox, any install will overwrite my changes. So I finally edited the xdg-open script to use rox for everything that is not http. I don't use Gnome, is there any gnome tool to configure xdg-open and the mime types?

Last edited by spupy (2009-11-16 14:46:34)


There are two types of people in this world - those who can count to 10 by using their fingers, and those who can count to 1023.

Offline

#8 2009-11-17 17:39:25

smyrman
Member
Registered: 2008-07-08
Posts: 6

Re: Best XDG Opener?

spupy wrote:

xdg-open is the devil. Or maybe I don't understand it, because I can't make it use the right programs to open files. When I make it open folders with rox instead of firefox, any install will overwrite my changes. So I finally edited the xdg-open script to use rox for everything that is not http. I don't use Gnome, is there any gnome tool to configure xdg-open and the mime types?

I use multiple DEs/WMs and the slim login manager. I found the best way to make sure xdg-open worked as I would like it to, was to add a little line in my ~/.xinitrc file:

export GNOME_DESKTOP_SESSION_ID="01" # fool xdg-open

By doing this I fool xdg-open to think I'm in gnome, and by doing so, programs like chromium-browser and others that use xdg-open, works good:-P

EDIT: Or better still! By adding one of the following lines to the top of .xinitrc (or to openbox autostart.sh):

export DE=kde
export DE=gnome

Last edited by smyrman (2009-11-20 18:16:40)

Offline

#9 2009-11-22 16:31:00

Pank
Member
From: IT
Registered: 2009-06-13
Posts: 370

Re: Best XDG Opener?

It seems that xdg-open will always use one's browser if one does not have a major DE (that is KDE, Gnome or XFCE). This is denoted generic in xdg-utils.
From the change log it seems that xdg-open would query mimeopen . This functionality is not present in xdg-open at the moment though. I might have something to do with this bug.

I found a nice patch that will make query mimeopen when using xdg-open.
The patch is located here.

Basically one just needs to change the open_generic() function in /usr/bin/xdg-open to:

open_generic()
{
    if mimeopen -v 2>/dev/null 1>&2; then
    mimeopen -n "$1"
    if [ $? -eq 0 ]; then
        exit_success
    fi
    fi

    IFS=":"
    for browser in $BROWSER; do
        if [ x"$browser" != x"" ]; then

            browser_with_arg=`echo "$browser" | sed s#%s#"$1"#`

            if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1";
            else $browser_with_arg;
            fi

            if [ $? -eq 0 ]; then exit_success;
            fi
        fi
    done

    exit_failure_operation_impossible "no method available for opening '$1'"
}

It works well for me. I don't know why the removed this IMO essential feature. They mention something about protocols in the bug report. . . If somebody knows more please enlighten me.

--Rasmus


Arch x64 on Thinkpad X200s/W530

Offline

#10 2009-12-05 20:37:12

Dirk Sohler
Member
From: Hamburg, Germany
Registered: 2009-10-03
Posts: 109

Re: Best XDG Opener?

Because i'm using PCManFM (which handles all file types very well and starts the correct applications) my xdg-open file looks like this:

[ -z "$1" ] && exit 1

if echo "${1}" | egrep -q "^(https?://|www.)"; then
    firefox "${1}" &
    exit
fi

pcmanfm "${1}"

Offline

#11 2009-12-14 13:09:34

Themaister
Member
From: Horten, Norway
Registered: 2008-07-21
Posts: 647
Website

Re: Best XDG Opener?

spupy wrote:

xdg-open is the devil. Or maybe I don't understand it, because I can't make it use the right programs to open files. When I make it open folders with rox instead of firefox, any install will overwrite my changes. So I finally edited the xdg-open script to use rox for everything that is not http. I don't use Gnome, is there any gnome tool to configure xdg-open and the mime types?

I made my own open-script, then I just force everything on my system to open files using that script. Simpler than messing around with 3-4 different regimes for opening goddamn files.

Offline

#12 2009-12-16 03:37:25

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,694
Website

Re: Best XDG Opener?

Nezmer wrote:

You mean something like mimeman

Mimeman can only be used to set associations but that inspired me to rip out some code from something else that I'd written to create Mimeo. It doesn't have URL support yet but that should be easy to add.

Offline

#13 2010-02-11 02:16:14

akshayshah
Member
Registered: 2009-05-23
Posts: 3

Re: Best XDG Opener?

It's been a while since this thread had any updates, but this problem was driving me *nuts* while using Chromium.  There's a really, really easy fix in this thread: http://bbs.archlinux.org/viewtopic.php?id=89053. Installing the perl-file-mimeinfo package made everything work without any further configuration.

@Pank, apparently the bug stopping xdg-open from using mimeopen has been squashed.

Offline

Board footer

Powered by FluxBB