LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-03-2010, 08:54 AM   #1
akamikeym
Member
 
Registered: May 2008
Posts: 104

Rep: Reputation: 21
xdg-open, gnome-open or kde(4?)-open???


Hi there,

I've just been trying to get Muzik Brainz Picard to open my preferred browser (chromium) on my Arch system that's XFCE only. Bizarrely it was opening 'elinks'. I realised that it was doing something weird with gnome-open so I had a look through the code and found this:

Code:
if sys.version_info >= (2, 5):
    # KDE default browser
    if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'):
        webbrowser.register('kfmclient', None, webbrowser.BackgroundBrowser(["kfmclient", "exec", "%s"]), update_tryorder=-1)
    # GNOME default browser
    if 'GNOME_DESKTOP_SESSION_ID' in os.environ and webbrowser._iscommand('gnome-open'):
        webbrowser.register('gnome-open', None, webbrowser.BackgroundBrowser(["gnome-open", "%s"]), update_tryorder=-1)


else:
    # KDE default browser
    if 'KDE_FULL_SESSION' in os.environ and os.environ['KDE_FULL_SESSION'] == 'true' and webbrowser._iscommand('kfmclient'):
        webbrowser.register('kfmclient', None, webbrowser.GenericBrowser("kfmclient exec '%s' &"))
        if 'BROWSER' in os.environ:
            webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'kfmclient')
        else:
            webbrowser._tryorder.insert(0, 'kfmclient')
    # GNOME default browser
    if 'GNOME_DESKTOP_SESSION_ID' in os.environ and webbrowser._iscommand('gnome-open'):
        webbrowser.register('gnome-open', None, webbrowser.GenericBrowser("gnome-open '%s' &"))
        if 'BROWSER' in os.environ:
            webbrowser._tryorder.insert(len(os.environ['BROWSER'].split(os.pathsep)), 'gnome-open')
        else:
            webbrowser._tryorder.insert(0, 'gnome-open')


if 'windows-default' in webbrowser._tryorder:
    class WindowsDefault2(webbrowser.BaseBrowser):
        def open(self, url, new=0, autoraise=1):
            try:
                os.startfile(url)
            except WindowsError:
                # [Error 22] No application is associated with the specified
                # file for this operation: '<URL>'
                return False
            else:
                return True

    webbrowser._tryorder.remove('windows-default')
    webbrowser.register('windows-default-2', WindowsDefault2,
                        update_tryorder=-1)

    iexplore = webbrowser.BackgroundBrowser(
        os.path.join(os.environ.get('PROGRAMFILES', 'C:\\Program Files'),
                     'Internet Explorer\\IEXPLORE.EXE'))
    webbrowser.register('iexplore', None, iexplore)
So I tried changing it to:

Code:
webbrowser.register('xdg-open', None, webbrowser.BackgroundBrowser(["xdg-open", "%s"]), update_tryorder=-1)
Which works fine for me.

Would I be right in thinking that xdg-open would work - at least for the whole linux section? Or does it nead all that gnome and kde specific junk?
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
gnome-open won't open new firefox windows ror Ubuntu 1 06-13-2007 03:00 PM
GNOME refuses to open certain file types without using the "open with" menu Xzyx987X Linux - Software 2 01-10-2007 06:15 PM
Can I have both KDE & Gnome desktops avail in open Suse 10.1? legacyprog Linux - Newbie 3 08-27-2006 02:15 PM
Open Office printer problems (KDE + Gnome) blastradius Ubuntu 2 08-09-2005 01:09 PM
How to Display/Open Gnome Applications in KDE? bongski55 Linux - General 2 07-08-2003 03:00 AM


All times are GMT -5. The time now is 02:26 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