DTG: Enable by default for Linux KDE and LXDE

Hide option on /configservice if not supported
This commit is contained in:
zzz
2020-10-12 11:24:08 +00:00
parent f77acb6db6
commit 5dc9333bb6
2 changed files with 26 additions and 12 deletions

View File

@ -1,5 +1,6 @@
package net.i2p.router.web; package net.i2p.router.web;
import java.awt.SystemTray;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
@ -202,9 +203,9 @@ public class ConfigServiceHandler extends FormHandler {
* @since 0.9.26 * @since 0.9.26
*/ */
public boolean shouldShowSystray() { public boolean shouldShowSystray() {
return ! return SystemTray.isSupported() &&
(SystemVersion.isLinuxService() || !SystemVersion.isService() &&
(SystemVersion.isWindows() && _context.hasWrapper() && WrapperManager.isLaunchedAsService())); !(SystemVersion.isWindows() && _context.hasWrapper() && WrapperManager.isLaunchedAsService());
} }
/** /**
@ -213,10 +214,7 @@ public class ConfigServiceHandler extends FormHandler {
* @since 0.9.26 * @since 0.9.26
*/ */
public boolean isSystrayEnabled() { public boolean isSystrayEnabled() {
// default false for now, except on OSX and non-service windows return RouterConsoleRunner.isSystrayEnabled(_context);
String sdtg = _context.getProperty(RouterConsoleRunner.PROP_DTG_ENABLED);
return Boolean.parseBoolean(sdtg) ||
(sdtg == null && (SystemVersion.isWindows() || SystemVersion.isMac()));
} }
/** /**

View File

@ -313,6 +313,26 @@ public class RouterConsoleRunner implements RouterApp {
return Server.getVersion(); return Server.getVersion();
} }
/**
* Package private for ConfigServiceHandler
* @since 0.9.48 pulled out of startTrayApp
*/
static boolean isSystrayEnabled(I2PAppContext _context) {
// default false except on OSX and non-service windows,
// and on Linux KDE and LXDE
// Xubuntu XFCE works but doesn't look very good
// Ubuntu Unity was far too buggy to enable
// Ubuntu GNOME does not work, SystemTray.isSupported() returns false
String xdg = System.getenv("XDG_CURRENT_DESKTOP");
boolean dflt = !SystemVersion.isService() &&
(SystemVersion.isWindows() ||
SystemVersion.isMac() ||
//"XFCE".equals(xdg) ||
"KDE".equals(xdg) ||
"LXDE".equals(xdg));
return _context.getProperty(PROP_DTG_ENABLED, dflt);
}
private void startTrayApp() { private void startTrayApp() {
// if no permissions, don't even try // if no permissions, don't even try
// isLaunchedAsService() always returns true on Linux // isLaunchedAsService() always returns true on Linux
@ -323,11 +343,7 @@ public class RouterConsoleRunner implements RouterApp {
return; return;
} }
try { try {
// default false for now, except on OSX and non-service windows if (isSystrayEnabled(_context)) {
String sdtg = _context.getProperty(PROP_DTG_ENABLED);
boolean desktopguiEnabled = Boolean.parseBoolean(sdtg) ||
(sdtg == null && (SystemVersion.isWindows() || SystemVersion.isMac()));
if (desktopguiEnabled) {
System.setProperty("java.awt.headless", "false"); System.setProperty("java.awt.headless", "false");
net.i2p.desktopgui.Main dtg = new net.i2p.desktopgui.Main(_context, _mgr, null); net.i2p.desktopgui.Main dtg = new net.i2p.desktopgui.Main(_context, _mgr, null);
dtg.startup(); dtg.startup();