This turns out to be dependent on how gnome-shell is restarted. I used to do this by typing gnome-shell --replace
in a gnome terminal. It turns out that commands run from gnome-terminal are not considered part of the session, but of the gnome-terminal service and this causes the problem. See loginctl user-status
for how your processes are grouped into sessions and services, or systemd-cgls
for al processes in the system.
To avoid this, restart gnome-shell using the shortcut Alt+F2 r
(Alt-F2 to open the run dialog, type r
as command, enter), or run gnome-shell --replace
from a terminal that does not run in its own service, such as xterm
.
Edit: apparently gnome-shell --replace
won't work anymore on Ubuntu 18.10+. See here