forked from dorkbox/SystemTray
Added more logging to gnome-shell extension installer
This commit is contained in:
parent
de46409b8f
commit
92ecb56bdc
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package dorkbox.systemTray.linux;
|
package dorkbox.systemTray.linux;
|
||||||
|
|
||||||
|
import static dorkbox.systemTray.SystemTray.logger;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -26,8 +28,6 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import dorkbox.systemTray.SystemTray;
|
import dorkbox.systemTray.SystemTray;
|
||||||
import dorkbox.util.Property;
|
import dorkbox.util.Property;
|
||||||
import dorkbox.util.process.ShellProcessBuilder;
|
import dorkbox.util.process.ShellProcessBuilder;
|
||||||
@ -38,7 +38,7 @@ class GnomeShellExtension {
|
|||||||
|
|
||||||
@Property
|
@Property
|
||||||
/** Permit the gnome-shell to be restarted when the extension is installed. */
|
/** Permit the gnome-shell to be restarted when the extension is installed. */
|
||||||
public static boolean ENABLE_SHELL_RESTART = false;
|
public static boolean ENABLE_SHELL_RESTART = true;
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
/** Default timeout to wait for the gnome-shell to completely restart. This is a best-guess estimate. */
|
/** Default timeout to wait for the gnome-shell to completely restart. This is a best-guess estimate. */
|
||||||
@ -48,7 +48,7 @@ class GnomeShellExtension {
|
|||||||
/** Command to restart the gnome-shell. It is recommended to start it in the background (hence '&') */
|
/** Command to restart the gnome-shell. It is recommended to start it in the background (hence '&') */
|
||||||
public static String SHELL_RESTART_COMMAND = "gnome-shell --replace &";
|
public static String SHELL_RESTART_COMMAND = "gnome-shell --replace &";
|
||||||
|
|
||||||
public static void install(final Logger logger, final String shellVersionString) throws IOException {
|
public static void install(final String shellVersionString) throws IOException {
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
|
||||||
PrintStream outputStream = new PrintStream(byteArrayOutputStream);
|
PrintStream outputStream = new PrintStream(byteArrayOutputStream);
|
||||||
|
|
||||||
@ -70,7 +70,6 @@ class GnomeShellExtension {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// have to copy the extension over and enable it.
|
// have to copy the extension over and enable it.
|
||||||
String userHome = System.getProperty("user.home");
|
String userHome = System.getProperty("user.home");
|
||||||
|
|
||||||
@ -106,6 +105,9 @@ class GnomeShellExtension {
|
|||||||
|
|
||||||
|
|
||||||
if (hasSystemTray) {
|
if (hasSystemTray) {
|
||||||
|
if (SystemTray.DEBUG) {
|
||||||
|
logger.debug("Checking current version of extension for upgrade");
|
||||||
|
}
|
||||||
// have to check to see if the version is correct as well (otherwise we have to reinstall it)
|
// have to check to see if the version is correct as well (otherwise we have to reinstall it)
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder(256);
|
StringBuilder builder = new StringBuilder(256);
|
||||||
@ -139,7 +141,7 @@ class GnomeShellExtension {
|
|||||||
} else {
|
} else {
|
||||||
// this means that we need to reinstall our extension, since either GNOME or US have changed versions since
|
// this means that we need to reinstall our extension, since either GNOME or US have changed versions since
|
||||||
// we last installed the extension.
|
// we last installed the extension.
|
||||||
hasSystemTray = false;
|
logger.debug("Need to upgrade extension");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +202,7 @@ class GnomeShellExtension {
|
|||||||
|
|
||||||
|
|
||||||
if (!hasSystemTray) {
|
if (!hasSystemTray) {
|
||||||
|
logger.debug("Enabling extension in gnome-shell");
|
||||||
// now we have to enable us if we aren't already enabled
|
// now we have to enable us if we aren't already enabled
|
||||||
|
|
||||||
// gsettings get org.gnome.shell enabled-extensions
|
// gsettings get org.gnome.shell enabled-extensions
|
||||||
@ -239,7 +242,7 @@ class GnomeShellExtension {
|
|||||||
stringBuilder.append("]");
|
stringBuilder.append("]");
|
||||||
|
|
||||||
// gsettings set org.gnome.shell enabled-extensions "['SystemTray@dorkbox']"
|
// gsettings set org.gnome.shell enabled-extensions "['SystemTray@dorkbox']"
|
||||||
// gsettings set org.gnome.shell enabled-extensions "['xyz', 'SystemTray@dorkbox']"
|
// gsettings set org.gnome.shell enabled-extensions "['background-logo@fedorahosted.org', 'SystemTray@dorkbox']"
|
||||||
final ShellProcessBuilder setGsettings = new ShellProcessBuilder(outputStream);
|
final ShellProcessBuilder setGsettings = new ShellProcessBuilder(outputStream);
|
||||||
setGsettings.setExecutable("gsettings");
|
setGsettings.setExecutable("gsettings");
|
||||||
setGsettings.addArgument("set");
|
setGsettings.addArgument("set");
|
||||||
@ -250,6 +253,12 @@ class GnomeShellExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ENABLE_SHELL_RESTART) {
|
if (ENABLE_SHELL_RESTART) {
|
||||||
|
if (SystemTray.DEBUG) {
|
||||||
|
logger.debug("DEBUG mode enabled. You need to manually restart the shell via '{}'", SHELL_RESTART_COMMAND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
logger.info("Restarting gnome-shell so tray notification changes can be applied.");
|
logger.info("Restarting gnome-shell so tray notification changes can be applied.");
|
||||||
|
|
||||||
// now we have to restart the gnome shell via bash
|
// now we have to restart the gnome shell via bash
|
||||||
|
Loading…
Reference in New Issue
Block a user