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() { boolean isUbuntu() {
return getInfo("ubuntu"); return getInfo("ubuntu");
} }
}
public static public static
class DesktopEnv { class DesktopEnv {
public static public static
boolean isGnome() { boolean isGnome() {
if (!OS.isLinux()) { if (!OS.isLinux() && !OS.isUnix()) {
return false; return false;
} }
@ -274,10 +275,15 @@ class OSUtil {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
PrintStream outputStream = new PrintStream(byteArrayOutputStream); 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); final ShellProcessBuilder shell = new ShellProcessBuilder(outputStream);
shell.setExecutable("ps"); shell.setExecutable("ps");
if (OS.isLinux()) {
shell.addArgument("a"); shell.addArgument("a");
} else {
shell.addArgument("x");
}
shell.start(); shell.start();
String output = ShellProcessBuilder.getOutput(byteArrayOutputStream); String output = ShellProcessBuilder.getOutput(byteArrayOutputStream);
@ -290,7 +296,7 @@ class OSUtil {
public static public static
String getGnomeVersion() { String getGnomeVersion() {
if (!OS.isLinux()) { if (!OS.isLinux() && !OS.isUnix()) {
return ""; return "";
} }
@ -340,7 +346,7 @@ class OSUtil {
// cannot represent '5.6.5' as a number, so we return a String instead // cannot represent '5.6.5' as a number, so we return a String instead
public static public static
String getPlasmaVersionFull() { String getPlasmaVersionFull() {
if (!OS.isLinux()) { if (!OS.isLinux() && !OS.isUnix()) {
return ""; return "";
} }
@ -372,5 +378,4 @@ class OSUtil {
return "0"; return "0";
} }
} }
}
} }