Is there an exact command for restarting GNOME Shell in Ubuntu 20.04 corresponding to Alt + F2 + 'r' + Enter?
The command for doing this is (Tested in Ubuntu 20.04 Only)
gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Meta.restart(_("Restarting…"))'
I also wanted to restart gnome shell programmatically because it seems there is some kind of memory leak in Ubuntu 19.10. gnome-shell
starts consuming a little over 200 MB but after several hours of use it can reach more than 900 MB.
alt+f2,r,enter
solves the problem gracefully. A small "restarting" message shows up. The change is almost unnoticeable, all windows maintain their position and running programs keep their state. Only the desktop background seems to flicker while it reloads.
When using gnome-shell --replace
some programs are killed with all the work in them lost, the windows that survive may change their position and several parts of the screen appear to be redrawn. I also tried killall gnome-shell
with similar results.
Unfortunately I don't think there is a way to access this functionality from the command line as it is embedded deep in the gnome-shell code for the RunDialog GObject:
gnome-shell > js > ui > runDialog.js [37]
this._internalCommands = {
'lg': () => Main.createLookingGlass().open(),
'r': this._restart.bind(this),
...