Skip to content

Commit 87458bd

Browse files
committed
Use xdg-open in PApplet#launch(String)
1 parent f775d44 commit 87458bd

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

core/src/processing/core/PApplet.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,11 +3351,6 @@ public void frameRate(float fps) {
33513351
* <p>
33523352
* When run with an applet, uses the browser to open the url,
33533353
* for applications, attempts to launch a browser with the url.
3354-
* <p>
3355-
* Works on Mac OS X and Windows. For Linux, use:
3356-
* <PRE>open(new String[] { "firefox", url });</PRE>
3357-
* or whatever you want as your browser, since Linux doesn't
3358-
* yet have a standard method for launching URLs.
33593354
*
33603355
* @param url the complete URL, as a String in quotes
33613356
*/
@@ -3430,25 +3425,20 @@ static public Process launch(String... args) {
34303425
params = new String[] { "open" };
34313426

34323427
} else if (platform == LINUX) {
3433-
if (openLauncher == null) {
3434-
// Attempt to use gnome-open
3428+
// xdg-open is in the Free Desktop Specification and really should just
3429+
// work on desktop Linux. Not risking it though.
3430+
final String[] launchers = {"xdg-open", "gnome-open", "kde-open"};
3431+
for (String l : launchers) {
3432+
if (openLauncher != null) break;
34353433
try {
3436-
Process p = Runtime.getRuntime().exec(new String[] { "gnome-open" });
3434+
Process p = Runtime.getRuntime().exec(new String[] { l });
34373435
/*int result =*/ p.waitFor();
34383436
// Not installed will throw an IOException (JDK 1.4.2, Ubuntu 7.04)
3439-
openLauncher = "gnome-open";
3440-
} catch (Exception e) { }
3441-
}
3442-
if (openLauncher == null) {
3443-
// Attempt with kde-open
3444-
try {
3445-
Process p = Runtime.getRuntime().exec(new String[] { "kde-open" });
3446-
/*int result =*/ p.waitFor();
3447-
openLauncher = "kde-open";
3437+
openLauncher = l;
34483438
} catch (Exception e) { }
34493439
}
34503440
if (openLauncher == null) {
3451-
System.err.println("Could not find gnome-open or kde-open, " +
3441+
System.err.println("Could not find xdg-, gnome-, or kde-open: " +
34523442
"the open() command may not work.");
34533443
}
34543444
if (openLauncher != null) {

0 commit comments

Comments
 (0)