GDM: how to switch user in command line?

Is there any official/bult-in way to switch user using command line? I know that I can lock screen by gnome-screensaver-command --lock (which is part of GNOME Flashback BTW) or loginctl lock-session but I want to lock screen AND switch to GDM greeter.

Basically I want to have shortcut to switch user but there is no such option in Settings/Devices/Keyboard. There is only “lock screen” which does not satisfy me. :wink: Now, I solved this problem by creating script in my ~/.local/bin (which I have in $PATH) and using it in manually added keyboard shortcut in desktop settings. The script is here:


loginctl lock-session

gdbus call \
    --system \
    --object-path /org/gnome/DisplayManager/LocalDisplayFactory \
    --dest org.gnome.DisplayManager \
    --method org.gnome.DisplayManager.LocalDisplayFactory.CreateTransientDisplay \
    > /dev/null

Is there better solution?

1 Like

Edit: Argh, sorry, that’s completely wrong. I had misread the part I’m quoting and thought it was about logging out, but it’s about locking the screen. Good job on reading comprehension @bochecha! :tired_face:

I don’t know how to answer your question, but for this specific bit:

The proper way, which should work on both GNOME and GNOME Flashback, would be:

gnome-session-quit --logout
1 Like

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