Added shell information restart and support for Ubuntu 18.04

This commit is contained in:
nathan 2018-10-25 10:56:47 +02:00
parent 80ac9545da
commit 9e007358ff
2 changed files with 55 additions and 4 deletions

View File

@ -38,6 +38,7 @@ import javax.swing.UIManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import dorkbox.systemTray.gnomeShell.DummyFile;
import dorkbox.systemTray.gnomeShell.Extension;
import dorkbox.systemTray.ui.awt._AwtTray;
import dorkbox.systemTray.ui.gtk._AppIndicatorNativeTray;
@ -306,14 +307,29 @@ class SystemTray {
return selectTypeQuietly(TrayType.GtkStatusIcon);
}
else if ("ubuntu".equalsIgnoreCase(GDM)) {
// ubuntu 17.10+ uses the NEW gnome DE, which screws up previous Ubuntu workarounds, since it's now proper Gnome
int[] version = OSUtil.Linux.getUbuntuVersion();
if (version[0] > 17 || (version[0] == 17 && version[1] == 10)) {
// this is gnome 3.26.1
// install the Gnome extension
// ubuntu 17.10+ uses the NEW gnome DE, which screws up previous Ubuntu workarounds, since it's now mostly Gnome
if (version[0] == 17 && version[1] == 10) {
// this is gnome 3.26.1, so we install the Gnome extension
Tray.usingGnome = true;
Extension.install();
}
else if (version[0] >= 18) {
// ubuntu 18.04 doesn't need the extension BUT does need a logout-login (or gnome-shell restart) for it to work
// we copy over a config file so we know if we have already restarted the shell or shown the warning. A logout-login will also work.
if (!DummyFile.isPresent()) {
DummyFile.install();
if (!Extension.ENABLE_EXTENSION_INSTALL) {
logger.warn("You must log out-in for the system tray to work.");
}
else {
Extension.restartShell();
}
}
}
return selectTypeQuietly(TrayType.AppIndicator);
}

View File

@ -0,0 +1,35 @@
package dorkbox.systemTray.gnomeShell;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import dorkbox.systemTray.SystemTray;
public
class DummyFile {
private static final File file = new File(System.getProperty("user.home") + "/.local/.SystemTray");
public static
boolean isPresent() {
return file.exists();
}
public static
void install() {
if (!file.exists()) {
if (SystemTray.DEBUG) {
SystemTray.logger.debug("Creating marker file");
}
try {
new FileOutputStream(file).close();
} catch (IOException e) {
SystemTray.logger.error("Error creating file", e);
}
}
file.setLastModified(System.currentTimeMillis());
}
}