Fixed issues with isGnome() detection on Unix (FreeBSD)

This commit is contained in:
nathan 2016-12-29 13:04:43 +01:00
parent d390b294b1
commit ee54ab39bc

View File

@ -261,12 +261,13 @@ class OSUtil {
boolean isUbuntu() {
return getInfo("ubuntu");
}
}
public static
class DesktopEnv {
public static
boolean isGnome() {
if (!OS.isLinux()) {
if (!OS.isLinux() && !OS.isUnix()) {
return false;
}
@ -274,10 +275,15 @@ class OSUtil {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
PrintStream outputStream = new PrintStream(byteArrayOutputStream);
// ps a | grep [g]nome-shell
// ps a | grep gnome-shell
// ps x | grep gnome-shell
final ShellProcessBuilder shell = new ShellProcessBuilder(outputStream);
shell.setExecutable("ps");
if (OS.isLinux()) {
shell.addArgument("a");
} else {
shell.addArgument("x");
}
shell.start();
String output = ShellProcessBuilder.getOutput(byteArrayOutputStream);
@ -290,7 +296,7 @@ class OSUtil {
public static
String getGnomeVersion() {
if (!OS.isLinux()) {
if (!OS.isLinux() && !OS.isUnix()) {
return "";
}
@ -340,7 +346,7 @@ class OSUtil {
// cannot represent '5.6.5' as a number, so we return a String instead
public static
String getPlasmaVersionFull() {
if (!OS.isLinux()) {
if (!OS.isLinux() && !OS.isUnix()) {
return "";
}
@ -373,4 +379,3 @@ class OSUtil {
}
}
}
}