Proper way to restart the shell from a script

I want to restart the Gnome Shell from within a script I’m working on.

While researching how other applications do this, I saw they use the dbus message system to communicate with the Shell using the following message : busctl --user call org.gnome.Shell /org/gnome/Shell org.gnome.Shell Eval s 'Meta.restart("Restarting…")'.

However, when executing this from either the terminal or from the script it does not restart the shell and just returns bs false "", which is the expected response unless unsafe mode is on.

Other strategies I found in the internet that try to restart the Shell externally like killall -HUP gnome-shell are buggy and workflow breaking.

Is there any “official” way to trigger a shell restart programmatically?

No. Restarting the compositor isn’t something applications are supposed to do, not least because on wayland it will terminate the session.

That makes sense.

What I’m really trying to do is to enable extensions after a manual installation (downloading and extracting it in the extensions folder), but the EnableExtension call does not enable it unless a restart is performed before.

Digging through the shell source code makes me suspect that the problem stems fromMain.extensionManager.loadExtension(extension)not being called when sending EnableExtension message through dbus.

Is that expected behavior or could it be considered a bug?

Yes. Extensions are scanned on startup, and new extensions are registered when installed via the InstallRemoteExtension D-Bus method.

Sideloading extensions is still possible, but neither encouraged nor officially supported.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.