Added proper XFCE check, added isXfce

This commit is contained in:
Robinson 2021-03-20 22:30:58 +01:00
parent 88fe8469be
commit 0410a83a62

View File

@ -657,13 +657,12 @@ class OSUtil {
// same thing with plasmashell! // same thing with plasmashell!
XDG = "kde"; XDG = "kde";
} }
else if (OSUtil.Linux.isIgel()) { else if (DesktopEnv.isXfce()) {
// https://github.com/dorkbox/SystemTray/issues/100 // https://github.com/dorkbox/SystemTray/issues/100
// IGEL linux doesn't say what it is... but we know it's XFCE // IGEL linux doesn't say what it is... but we know it's XFCE ... EVEN THOUGH it reports X11!!
XDG = "xfce"; XDG = "xfce";
} }
// Ubuntu Unity is a weird combination. It's "Gnome", but it's not "Gnome Shell". // Ubuntu Unity is a weird combination. It's "Gnome", but it's not "Gnome Shell".
if ("unity".equalsIgnoreCase(XDG)) { if ("unity".equalsIgnoreCase(XDG)) {
return Env.Unity; return Env.Unity;
@ -931,6 +930,40 @@ class OSUtil {
return null; return null;
} }
private static volatile Boolean isXfce = null;
public static
boolean isXfce() {
if (!OS.isLinux() && !OS.isUnix()) {
return false;
}
if (isXfce != null) {
return isXfce;
}
try {
// note: some versions of linux can ONLY access "ps a"; FreeBSD and most linux is "ps x"
// we try "x" first
// ps x | grep xfce
boolean contains = Executor.Companion.run("ps", "x").contains("xfce");
if (!contains && OS.isLinux()) {
// only try again if we are linux
// ps a | grep gnome-shell
contains = Executor.Companion.run("ps", "a").contains("xfce");
}
isXfce = contains;
return isXfce;
} catch (Throwable ignored) {
}
isXfce = false;
return isXfce;
}
private static volatile Boolean isNautilus = null; private static volatile Boolean isNautilus = null;
/** /**
@ -1019,11 +1052,13 @@ class OSUtil {
// xfconf-query -c xfce4-panel -l // xfconf-query -c xfce4-panel -l
List<String> commands = new ArrayList<>(); List<String> commands = new ArrayList<>();
commands.add("xfconf-query"); commands.add("xfconf-query");
commands.add("-c " + channel); commands.add("-c");
commands.add(channel);
if (property != null) { if (property != null) {
// get property for channel // get property for channel
commands.add("-p " + property); commands.add("-p");
commands.add(property);
} else { } else {
// list all properties for the channel // list all properties for the channel
commands.add("-l"); commands.add("-l");