Skip to content

Commit acb91c6

Browse files
author
Nep Nep
authored
Fix opening URLs on linux without gnome (#362)
1 parent 0163f28 commit acb91c6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/main/kotlin/com/lambda/client/util/WebUtils.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ object WebUtils {
5757

5858
fun openWebLink(url: String) {
5959
try {
60-
Desktop.getDesktop().browse(URI(url))
60+
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
61+
Desktop.getDesktop().browse(URI(url))
62+
} else {
63+
val exitCode = Runtime.getRuntime().exec(arrayOf("xdg-open", url)).waitFor()
64+
if (exitCode != 0) {
65+
LambdaMod.LOG.error("Couldn't open link, xdg-open returned: $exitCode")
66+
}
67+
}
6168
} catch (e: IOException) {
6269
LambdaMod.LOG.error("Couldn't open link: $url")
6370
}

0 commit comments

Comments
 (0)