Skip to content

Commit

Permalink
Wait until the desktop ends starting up
Browse files Browse the repository at this point in the history
Gnome Shell enables the extensions before the desktop itself is
ready to accept widgets. This can result in errors. In the case
of appindicator, it results in applications that are launched
during startup will not show an indicator because, when the
extension tries to add the icon to the Gnome Shell interface,
it isn't ready for that, thus failing. But other applications,
launched after the Shell has completed the startup process,
will work fine.

This patch fixes this by checking in the `enable()` method if
Gnome Shell is still starting up, in which case it waits until
the `startup-complete` signal is triggered before continuing.
  • Loading branch information
Sergio Costas committed Apr 25, 2020
1 parent b50bdcb commit b2aff4b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
const Gio = imports.gi.Gio
const GLib = imports.gi.GLib
const Main = imports.ui.main;

const Extension = imports.misc.extensionUtils.getCurrentExtension()

Expand All @@ -24,6 +25,7 @@ const Util = Extension.imports.util
let statusNotifierWatcher = null;
let isEnabled = false;
let watchDog = null;
let startupPreparedId;

function init() {
watchDog = new NameWatchdog();
Expand Down Expand Up @@ -51,11 +53,21 @@ function maybe_enable_after_name_available() {
statusNotifierWatcher = new StatusNotifierWatcher.StatusNotifierWatcher(watchDog);
}

function enable() {
function inner_enable(disconnect_startup_complete) {
if (disconnect_startup_complete)
Main.layoutManager.disconnect(startupPreparedId);
isEnabled = true;
maybe_enable_after_name_available();
}

function enable() {
// If the desktop is still starting up, we wait until it is ready
if (Main.layoutManager._startingUp)
startupPreparedId = Main.layoutManager.connect('startup-complete', () => { inner_enable(true); });
else
inner_enable(false);
}

function disable() {
isEnabled = false;
if (statusNotifierWatcher !== null) {
Expand Down

0 comments on commit b2aff4b

Please sign in to comment.