diff --git a/src/main/java/com/sparrowwallet/sparrow/Interface.java b/src/main/java/com/sparrowwallet/sparrow/Interface.java index 56ac68c1..90a1ff57 100644 --- a/src/main/java/com/sparrowwallet/sparrow/Interface.java +++ b/src/main/java/com/sparrowwallet/sparrow/Interface.java @@ -7,7 +7,15 @@ public enum Interface { public static Interface get() { if(currentInterface == null) { - currentInterface = DESKTOP; + 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; + } } return currentInterface; diff --git a/src/main/java/com/sparrowwallet/sparrow/SparrowWallet.java b/src/main/java/com/sparrowwallet/sparrow/SparrowWallet.java index 9838e98a..230f28f8 100644 --- a/src/main/java/com/sparrowwallet/sparrow/SparrowWallet.java +++ b/src/main/java/com/sparrowwallet/sparrow/SparrowWallet.java @@ -86,13 +86,21 @@ public class SparrowWallet { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); - if(args.terminal || java.awt.GraphicsEnvironment.isHeadless()) { + if(args.terminal) { Interface.set(Interface.TERMINAL); - PlatformImpl.setTaskbarApplication(false); - Drongo.removeRootLogAppender("STDOUT"); - com.sun.javafx.application.LauncherImpl.launchApplication(SparrowTerminal.class, SparrowWalletPreloader.class, argv); - } else { - com.sun.javafx.application.LauncherImpl.launchApplication(SparrowDesktop.class, SparrowWalletPreloader.class, argv); + } + + try { + if(Interface.get() == Interface.TERMINAL) { + PlatformImpl.setTaskbarApplication(false); + Drongo.removeRootLogAppender("STDOUT"); + com.sun.javafx.application.LauncherImpl.launchApplication(SparrowTerminal.class, SparrowWalletPreloader.class, argv); + } else { + 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"); } }