How can I check if Gnome has finished loading?

Take the very simple script below, that disables a specific extension :

#!/usr/bin/env bash
EXTENSION="harddiskled@bijidroid.gmail.com"
gnome-extensions disable $EXTENSION
exit 0

The script works as intended.

However, if I put that script in ~/.config/autostart, then the whole OS sort of freezes after login into Gnome. I say “sort of”, because Gnome seems to start correctly, seems to “live” correctly (the clock in the panel works, I can see other extensions like CPU load in the panel varying, and so on). However, I have no control, neither the mouse nor the keyboard respond.

Worse, I can not even access another console (<Ctrl><Alt><F3> for example). I have to physically shut down the laptop (long press on power button), boot Linux into recovery mode, and delete (or modify) the script in ~/.config/autostart.

Now, if I add a sleep 3 right before gnome-extensions disable $EXTENSION, it works (sleep 1 doesn’t work either, I haven’t tested sleep 2).

So, it seems I try to run gnome-extensions disable $EXTENSION too early in the startup process of Gnome Shell, thus the freezing. Is there something more elegant than sleep 3 to detect if Gnome Shell has finished loading ?

I have to ask:
What is it that you actually want to achieve with this?

Because this sound a lot like an XY Problem.

That specific extension (Harddisk LED - GNOME Shell Extensions) doesn’t show at its designed place in the top panel. extension.js is like :

Main.panel._centerBox.insert_child_at_index(button, 0);

_centerBox is enforced, but not the index (0) : after login, the icon can be anywhere in the top panel’s center area.

I’m using another extension (Top Bar Organizer - GNOME Shell Extensions) to reorder the items of the top panel, but that specified Harddisk LED icon isn’t detected by this extension.

I eventually found out that disabling and enabling the extension right after login makes it go to its designed place.

So I wrote the following autostart script :

#!/usr/bin/env bash
EXTENSION="harddiskled@bijidroid.gmail.com"
sleep 3
gnome-extensions disable $EXTENSION && gnome-extensions enable $EXTENSION
exit 0

It works perfectly, but needs the sleep 3. Thus my question, is there a more elegant way to do this ? Something like (pseudo-code) :

IF gnome-shell_has_finished_to_load
THEN do_your_thing

So, this really is an XY Problem, with the actual issue being “On login, the top bar organizer does not move the indicator of another extension to the right place”.

Now, the actual solution would be to find out what causes the issue in the first place[1] and fix it in the extension. So, ideally you would report an issue to the extension.

Until the issue can be properly resolved, the script is well enough as a stop-gap.


  1. My guess would be that the Harddisk LED extension uses an unusual widget combination (I think icon + button), which the top bar organizer extension doesn’t know how to sort right. ↩︎

Answering my own question

I accidentally found out what happened. If I enable No overview at start-up - GNOME Shell Extensions, there is no more freezing, and my script works well.

So, it seems that launching $ gnome-extensions ... in a script right after login doesn’t play well with the initial overview.

Anyway, case closed, I just enable No overview at start-up - GNOME Shell Extensions, and my script works fine, without sleep.