From cf62fd7ed5379ccf00b40679906a7394d3ed4747 Mon Sep 17 00:00:00 2001 From: nathan Date: Sun, 17 Sep 2017 23:52:32 +0200 Subject: [PATCH] Added SystemTray.ENABLE_ROOT_CHECK --- README.md | 8 +++++++- src/dorkbox/systemTray/SystemTray.java | 13 +++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0fbba8d..b658dd2 100644 --- a/README.md +++ b/README.md @@ -149,6 +149,12 @@ SystemTray.ENABLE_SHUTDOWN_HOOK (type boolean, default value 'true') SystemTray.AUTO_FIX_INCONSISTENCIES (type boolean, default value 'true') - Allows the SystemTray logic to resolve various OS inconsistencies for the SystemTray in different combinations + + +SystemTray.ENABLE_ROOT_CHECK (type boolean, default value 'true') + - Allows the SystemTray logic to ignore if root is detected. Usually when running as root it won't work (because of + how DBUS operates), but in rare situations, it might work. + This is an advanced feature, and it is recommended to leave as true SystemTray.SWING_UI (type SwingUIFactory, default value 'null') @@ -265,7 +271,7 @@ Maven Info com.dorkbox SystemTray - 3.6 + 3.7 ```` diff --git a/src/dorkbox/systemTray/SystemTray.java b/src/dorkbox/systemTray/SystemTray.java index 46fccd2..eb3c754 100644 --- a/src/dorkbox/systemTray/SystemTray.java +++ b/src/dorkbox/systemTray/SystemTray.java @@ -129,6 +129,15 @@ class SystemTray { */ public static boolean AUTO_FIX_INCONSISTENCIES = true; + @Property + /** + * Allows the SystemTray logic to ignore if root is detected. Usually when running as root it won't work (because of how DBUS + * operates), but in rare situations, it might work. + *

+ * This is an advanced feature, and it is recommended to leave as true + */ + public static boolean ENABLE_ROOT_CHECK = true; + @Property /** * Allows a custom look and feel for the Swing UI, if defined. See the test example for specific use. @@ -742,7 +751,7 @@ class SystemTray { } } - if (isTrayType(trayType, TrayType.AppIndicator) && OSUtil.Linux.isRoot()) { + if (SystemTray.ENABLE_ROOT_CHECK && isTrayType(trayType, TrayType.AppIndicator) && OSUtil.Linux.isRoot()) { // if are we running as ROOT, there can be issues (definitely on Ubuntu 16.04, maybe others)! if (AUTO_FIX_INCONSISTENCIES) { trayType = selectTypeQuietly(TrayType.Swing); @@ -990,7 +999,7 @@ class SystemTray { */ public static String getVersion() { - return "3.6"; + return "3.7"; } /**