On Ubuntu, you can type Alt-F2 to get the "Run Command" prompt, you can just type
r there, and the desktop GUI will be restarted, without the need to log off and log on again ...
Here are a bit more details on this procedure for Ubuntu Gnome3: https://linuxconfig.org/how-to-restart-gui-on-ubuntu-20-04-focal-fossa
However, I cannot do the same on Raspbian Stretch:
... since Alt-F2 +
r fails with:
Failed to execute child process "r" (No such file or directory).
The above link mentions that in Ubuntu Gnome3, Alt-F2 +
r is equivalent to the commands:
gnome-shell --replace(sudo not required); or
sudo systemctl restart systemd-logind(sudo required).
sudo systemctl restart systemd-logind on Raspbian Stretch - but it looks like it does not restart the desktop GUI.
I also found this post: https://unix.stackexchange.com/questions/518001/what-commands-are-run-by-altf2-and-r - and for cinnamon desktop, apparently the commands are:
pkill -HUP -f "cinnamon --replace"
dbus-send --type=method_call --print-reply --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:'global.reexec_self()'(this is also for Gnome desktop)
dbus-send --type=method_call --print-reply --dest=org.Cinnamon /org/Cinnamon org.Cinnamon.Eval string:'global.reexec_self()'
So - is there a similar "restart GUI" command that I can use in Raspbian without sudo? (I'm interested in the command line - but ultimately, I would want to put it as a shortcut in the Raspberry menu...)