Opened 15 years ago

Closed 15 years ago

Last modified 12 years ago

#5629 closed enhancement (fixed)

[Patch] Use xdg-open first for opening links — at Version 7

Reported by: quazgar Owned by: team
Priority: minor Milestone: 14.01
Component: Core Version: latest
Keywords: Cc:

Description (last modified by simon04)

Currently gnome-open is used as the first helper application to open links, regardless of which window manager is used.

The attached patch used xdg-open (from freedesktop.org) as the first try. If that fails, the other alternatives are used in the order used before. This should work for all modern window managers equally well.

I suggest applying this patch to the current source, I tried & tested it with latest svn (3652), it compiles and runs fine.

Change History (8)

by quazgar, 15 years ago

Attachment: 0001.xdg-open.patch added

Patch to implement the proposed change

comment:1 by stoecker, 15 years ago

Summary: Patch: Use xdg-open first for opening links[Patch] Use xdg-open first for opening links

comment:2 by bastiK, 15 years ago

See #5108.

The code you patched is not executed under normal circumstances.

From OpenBrowser.java:

        if (Desktop.isDesktopSupported()) {
            try {
                Desktop.getDesktop().browse(uri);
            } catch (Exception e) {
                e.printStackTrace();
                return e.getMessage();
            }
        } else {
            System.err.println("Warning: Desktop class is not supported. Platform dependent fall back for open url in browser.");

            if (Main.platform == null)
                throw new IllegalStateException(tr("Failed to open URL. There is currently no platform set. Please set a platform first."));
            try {
                Main.platform.openUrl(uri.toString());
            } catch (IOException e) {
                return e.getMessage();
            }
        }

Desktop.isDesktopSupported() should return true on all modern platforms.

Maybe like this:

(1) xdg-open

(2) Desktop.getDesktop().browse()

(3) gnome-open, kfmclient openURL, firefox

in reply to:  2 comment:3 by anonymous, 15 years ago

Replying to bastiK:

See #5108.

The code you patched is not executed under normal circumstances.

From OpenBrowser.java:
...

True, I didn't check if gnope-open was still used here with the latest svn version :) I just experienced the mentioned problem with the version I had installed (r3514), but the mentioned change seems to have been done in r3524.

Maybe like this:

(1) xdg-open

(2) Desktop.getDesktop().browse()

(3) gnome-open, kfmclient openURL, firefox

If someone wants to implement this order, I'd really welcome it, but it's no high priority for me any more :)

I'm just not sure though if all supported Desktops porperly configure, so maybe it should be simply

(1) Desktop.getDesktop().browse()

(2) xdg-open, gnome-open, kfmclient openURL, firefox

I would rather leave this decision to desktop environment experts though.

comment:4 by bastiK, 15 years ago

Resolution: duplicate
Status: newclosed

comment:5 by bastiK, 15 years ago

Closed as duplicate of #5108.

comment:6 by anonymous, 13 years ago

Please merge this patch. I understand that this code does not execute for a large percentage of your users, but it's 12 bytes, and helps those of us with unusual window managers (like me, and the person who sent in the patch.)

comment:7 by simon04, 13 years ago

Description: modified (diff)

+1. xdg-open seems to be standard for opening files by extension under Linux.

Note: See TracTickets for help on using tickets.