Skip to content

Commit

Permalink
[browser] open with browser feature is broken on recent linux version…
Browse files Browse the repository at this point in the history
… due to a bug in java desktop, adding a workaround
  • Loading branch information
rmannibucau committed Dec 13, 2023
1 parent 85f6fe3 commit 7f3c6f5
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,17 @@ public void open(final boolean openBrowser) {
}
try {
java.awt.Desktop.getDesktop().browse(uri);
} catch (final IOException e) {
logError.accept("Desktop is not supported on this JVM, go to " + uri + " in your browser (" + e.getMessage() + ")", e);
} catch (final IOException | RuntimeException e) { // seems broken on recent linux version and java is a bit late to fix it
try {
final var xdgOpen = Path.of("/usr/bin/xdg-open");
if (Files.exists(xdgOpen)) {
new ProcessBuilder(xdgOpen.toString(), uri.toString()).start().waitFor();
} // else todo
} catch (final InterruptedException ie) {
Thread.currentThread().interrupt();
} catch (final RuntimeException | IOException re) {
logError.accept("Desktop is not supported on this JVM, go to " + uri + " in your browser (" + e.getMessage() + ")", e);
}
}
}
}

0 comments on commit 7f3c6f5

Please sign in to comment.