mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-04-29 22:24:32 +02:00
Fallback to xdg-open on Linux when opening URLs (#279)
This also prevents MegaBasterd from hanging at startup if it fails opening the MEGA SDK URL. Co-authored-by: guihkx <guihkx@users.noreply.github.com>
This commit is contained in:
parent
798f6f28e7
commit
b446dba7c9
@ -1110,8 +1110,20 @@ public class MiscTools {
|
||||
public static void openBrowserURL(final String url) {
|
||||
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
} catch (URISyntaxException | IOException ex) {
|
||||
Logger.getLogger(MiscTools.class.getName()).log(Level.INFO, "Trying to open URL in external browser: {0}", url);
|
||||
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(new URI(url));
|
||||
return;
|
||||
}
|
||||
if (System.getProperty("os.name").toLowerCase().contains("nux")) {
|
||||
Process p = Runtime.getRuntime().exec(new String[] { "xdg-open", url });
|
||||
p.waitFor();
|
||||
p.destroy();
|
||||
return;
|
||||
}
|
||||
Logger.getLogger(MiscTools.class.getName()).log(Level.WARNING, "Unable to open URL: Unsupported platform.", url);
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(MiscTools.class.getName()).log(Level.SEVERE, ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user