Can I use `` to detect when the Meta is about to restart?


I’m trying to know when the Meta is about to restart in a Gnome Shell extension. Below is the code that I’m using to do that:

global.display.connect('show-restart-message', (display, message) => {
    log('showing restart message ' + message)
    this._meta_is_restarting = true;
    return false;

But it does not work at all. I don’t see showing restart message is printing in the logs. Gnome shell itself is using this signal to show a restarting message on the cluster stage, I’m not sure why the above code does not work for me.

I’m not sure why the above code does not work for me.

The signal uses an accumulator that stops the emission after the first handler returns true. That’s the case for the shell handler, and that will always run before any handler connected by extensions (because it is set up before the extension system is initialized).

What exactly are you trying to achieve?

On X11, If the Meta is about to restart, I need to set a flag, which is _meta_is_restarting.

During the meta restart, MetaWindows will all be destroyed and emit MetaWindow::unmanaging and ShellApp::state signals. When this happens, I just need to check _meta_is_restarting (in L281 in below code) to prevent running some code (L283-L291).

I’m not worry about restart via killall -3 gnome-shell, since it won’t emit MetaWindow::unmanaging and ShellApp::state signals.

The below code works for me:

_overrideMetaRestart() {
    const that = this;
    _meta_restart = Meta.restart;
    Meta.restart = function (message, context) {
        that._meta_is_restarting = true;
        _meta_restart(message, context);



work in that case?


Meta.is_restart() only works after Meta.restart(), it’s too later for my code working expectedly. In my case, I need a function like Meta.is_about_to_restart(), right before Meta.restart().

Meta.is_restart() means the Meta has been restarted (once or many times, because I can restart gnome-shell many times), right?

The reason that I want to do this is because, after restart, some window states are lost, like the edge tiling, and for some apps like VS Code Or Brave, they lost the maximization, for Brave, the window size could become very small.