mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
improve detection and handling on headless systems
This commit is contained in:
parent
ab2c77695b
commit
ed69a86529
2 changed files with 23 additions and 7 deletions
|
@ -7,8 +7,16 @@ public enum Interface {
|
||||||
|
|
||||||
public static Interface get() {
|
public static Interface get() {
|
||||||
if(currentInterface == null) {
|
if(currentInterface == null) {
|
||||||
|
if(java.awt.GraphicsEnvironment.isHeadless()) {
|
||||||
|
if("Monocle".equalsIgnoreCase(System.getProperty("glass.platform"))) {
|
||||||
|
currentInterface = TERMINAL;
|
||||||
|
} else {
|
||||||
|
throw new UnsupportedOperationException("Headless environment detected but Monocle platform not found");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
currentInterface = DESKTOP;
|
currentInterface = DESKTOP;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return currentInterface;
|
return currentInterface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,14 +86,22 @@ public class SparrowWallet {
|
||||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
||||||
SLF4JBridgeHandler.install();
|
SLF4JBridgeHandler.install();
|
||||||
|
|
||||||
if(args.terminal || java.awt.GraphicsEnvironment.isHeadless()) {
|
if(args.terminal) {
|
||||||
Interface.set(Interface.TERMINAL);
|
Interface.set(Interface.TERMINAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if(Interface.get() == Interface.TERMINAL) {
|
||||||
PlatformImpl.setTaskbarApplication(false);
|
PlatformImpl.setTaskbarApplication(false);
|
||||||
Drongo.removeRootLogAppender("STDOUT");
|
Drongo.removeRootLogAppender("STDOUT");
|
||||||
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowTerminal.class, SparrowWalletPreloader.class, argv);
|
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowTerminal.class, SparrowWalletPreloader.class, argv);
|
||||||
} else {
|
} else {
|
||||||
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowDesktop.class, SparrowWalletPreloader.class, argv);
|
com.sun.javafx.application.LauncherImpl.launchApplication(SparrowDesktop.class, SparrowWalletPreloader.class, argv);
|
||||||
}
|
}
|
||||||
|
} catch(UnsupportedOperationException e) {
|
||||||
|
getLogger().error("Unable to launch application", e);
|
||||||
|
System.out.println("Use Sparrow Server on a headless (no display) system");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Instance getSparrowInstance() {
|
public static Instance getSparrowInstance() {
|
||||||
|
|
Loading…
Reference in a new issue