Added XFCE query commands

This commit is contained in:
nathan 2017-06-25 23:52:28 +02:00
parent 19b9efe6c2
commit 66dc5447a0
1 changed files with 42 additions and 0 deletions

View File

@ -602,5 +602,47 @@ class OSUtil {
return "0";
}
/**
* @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
*
* @return the property value or "".
*/
public static
String queryXfce(String channel, String property) {
if (!OS.isLinux() && !OS.isUnix()) {
return "";
}
if (channel == null) {
return "";
}
try {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
PrintStream outputStream = new PrintStream(byteArrayOutputStream);
// xfconf-query -c xfce4-panel -l
final ShellProcessBuilder xfconf_query = new ShellProcessBuilder(outputStream);
xfconf_query.setExecutable("xfconf-query");
xfconf_query.addArgument("-c " + channel);
if (property != null) {
// get property for channel
xfconf_query.addArgument("-p " + property);
} else {
// list all properties for the channel
xfconf_query.addArgument("-l");
}
xfconf_query.start();
return ShellProcessBuilder.getOutput(byteArrayOutputStream);
} catch (Throwable e) {
e.printStackTrace();
}
return "";
}
}
}