How to lock screen on suspend?

The forum software changed the double-dash ("--")in the filename to a Unicode emdash ( "–", \xe2\x80\x93). If you look real close, you will see that the dash between loginctl and lock is slighty wider than the dash separating lock and sessions. Systemctl doesn't like Unicode dashes.

If you name the file /etc/systemd/system/loginctl--lock-sessions.service, and enable it using systemctl enable loginctl--lock-sessions.service it will work.


Big thanx !!!
Worked for me on 20.04 too.
U R The Boss :pray:

Same issue on UM 22.04.
Your solution works great!
Thank you!

How to Invoke a Locking Suspend When Using Ubuntu MATE 22.04 LTS on a Desktop

With Ubuntu MATE 22.04 LTS, there are three possible ways to suspend a desktop computer:

(1) A non-locking suspend: Menu -> Turn off the device -> Suspend

(2) A Switch-User Locking Suspend: Menu -> End the current session -> Switch User -> Suspend

(3) A Power-Management Locking Suspend: Menu -> Preferences -> Power Management -> On AC Power -> Put the computer to sleep when inactive for 10 minutes -> Minimize -> Menu -> Lock the screen

N.B: All of this is necessary for the simple reason that there is no suspend button on the lock screen. . . .

N.B: Even when the keyboard's physical suspend button is assigned to suspend, it will not respond when the screen is locked. Therefore, you will need to set power management to put the computer to sleep when inactive for the shortest amount of time, which, these days, happens to be 10 minutes. . . .


Welcome @JCS to the community!

On a previous occasion, I posted a description of the built-in methods for getting a locking suspend on Ubuntu MATE 22.04 LTS:

Since then, I have found the BEST SOLUTION YET for getting a proper, reliable locking suspend on Ubuntu MATE 22.04 LTS:

There's a cute little program sitting in the Ubuntu repository called "qshutdown." Use your favorite package manager to install it. Launch it, get to know it, and set its preferences. (You'll be able to do this fairly quickly.) Then, all you'll need to do to have a proper locking suspend IN SIXTY SECONDS (instead of in ten minutes) is Menu -> qshutdown, Menu -> Lock the screen.

You can use qshutdown for one-minute locking suspends and continue to use the MATE menu for shutdown, restart, log out, and switch user. You'll no longer need to use the built-in MATE methods for getting locking suspends.

Problem solved.


Was getting irritated by this, so searched for a solution ... only to find I'd found the same thread 5 years ago. Still not fixed then.

ya, I gave up and ended up installing i3lock and mapping it to Super B, combined with screen shut off in power options. I still think its a bit silly that this has been an issue for so many years without a resolution.