From ab8e7e5a796c93890a60fbc599ea19de5febbf48 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 23 Jul 2017 14:16:41 +0200 Subject: [PATCH] Added ChromeOS detection --- src/dorkbox/util/OSUtil.java | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/dorkbox/util/OSUtil.java b/src/dorkbox/util/OSUtil.java index c23660d..0873068 100644 --- a/src/dorkbox/util/OSUtil.java +++ b/src/dorkbox/util/OSUtil.java @@ -410,6 +410,7 @@ class OSUtil { XFCE, LXDE, Pantheon, + ChromeOS, Unknown, } @@ -459,12 +460,18 @@ class OSUtil { return Env.Gnome; } + // maybe it's chromeOS? + if (isChromeOS()) { + return Env.ChromeOS; + } + return Env.Unknown; } private static volatile Boolean isGnome = null; private static volatile Boolean isKDE = null; + private static volatile Boolean isChromeOS = null; public static boolean isGnome() { @@ -612,6 +619,37 @@ class OSUtil { } + public static + boolean isChromeOS() { + if (isChromeOS == null) { + if (!OS.isLinux()) { + isChromeOS = false; + return false; + } + + try { + // ps aux | grep chromeos + final ShellExecutor shellVersion = new ShellExecutor(); + shellVersion.setExecutable("ps"); + shellVersion.addArgument("aux"); + shellVersion.start(); + + String output = shellVersion.getOutput(); + + if (!output.isEmpty()) { + if (output.contains("chromeos")) { + isChromeOS = true; + return true; + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + + return isChromeOS; + } + /** * @param channel which XFCE channel to query. Cannot be null * @param property which property (in the channel) to query. Null will list all properties in the channel