0

I've used multiple Linux Ubuntu 20 and 22 systems, and most of them work "out of the box" with Super+L (aka Windows+L) configured to lock the screen.

On one machine, however, it doesn't work even though it is configured. See screenshot:
Ubuntu Settings | Keyboard Shortcuts

Another co-worker also experienced this problem.

My question is Why doesn't Super+L when it is properly configured lock the screen? What is the command that is run?

Searching for solution

I've tried searching for reasons Super+L does not work but haven't found anything useful.

Most of the solutions like this one, assume that Super+L is not configured and they explain how to configure Super+L. In my case, Super+L is configured but it is not working.

If I knew the command that Super+L was configured to run then, I might be able to track down the problem myself.
I found:

  • gnome-screensaver-command -l as shown here but that didn't show any command (which may or may not be the problem).
  • xdg-screensaver lock - does nothing
  • mate-screensaver-command -l - command not found
  • and others

My Solution

My solution was to do the following:

  1. Find a command command to lock the screen.
    In my case, I found that using dm-tool lock worked. See UPDATE below

  2. Create a custom shortcut for Super+L to run that command.

This makes it clear (to me) that Super+L is being received by the OS and can work (if properly configured to do so).

2025-05-07 UPDATE: After this was answered, I learned that using dm-tool was not the correct solution so please don't use it. I leave it in only for the purposes of maintaining the original post.

PatS
  • 616

1 Answers1

1

Why doesn't Super+L when it is properly configured lock the screen?

Ubuntu uses GNOME as its default desktop environment. Its screen-locker is integrated into GNOME Shell, rather than being an external program, and most of it is the exact same code as is used for displaying the login screen of GNOME's standard GDM "display manager" (the software which starts X11 on startup and shows the graphical logon screen).

But it's a mutual dependency – the GNOME screen-locker also relies on GDM being present to handle the actual password checking. This avoids the need for gnome-shell to directly interact with PAM components (like gnome-screensaver would have needed in the past), as well as allowing it to make use of GDM's existing "parallel authentication" code: for example, GDM can wait for password and fingerprint simultaneously, using two concurrent PAM stacks – something that regular standalone screensavers don't even try to implement.

Since you say dm-tool works, that means your system is using LightDM and not GDM, and therefore GNOME Shell doesn't have the "password checking" component so its lock screen cannot function.

LightDM used to be Ubuntu's default display manager back when it came with Unity. Nowadays I think it is still the default for the Xfce flavor if that's still a thing. So it might be that GDM never got installed when the system was upgraded.

What command should be running?

Really none, as the shortcut directly performs an internal call between gnome-shell components, and no new program is launched to display the screenshield.

But from what I remember, gnome-screensaver-command is still suitable if present - it thinks it's calling a running gnome-screensaver process but it's really calling gnome-shell. However, it's not guaranteed to be installed at all. (The call could probably be done using gdbus as well.)

There is also a loginctl lock-session, which sends a generic "please lock" signal to the desktop environment – GNOME Shell recognizes it.

In my case, I found that using dm-tool lock worked.

I'm having some doubts about this; it switches you to the LightDM login screen but does it actually prevent you from Ctrl-Alt-F7'ing back to the desktop?

The display manager only launches the displays, but has no further control – it can't really "lock" them afterwards. At most, it could prevent the Ctrl-Alt-Fx shortcuts from working once you switch to the login screen, but that's not generally done; it has its own downsides.

I think the GDM equivalent of this would be the gdmflexiserver command.

grawity
  • 501,077