Score:0

Ubuntu 21.10 won't suspend when lid closed

in flag

I have a mid-2012 13" Unibody MacBook Pro running Ubuntu Linux 21.10. I typically use this computer to play Minecraft. When I sign in, there are no performance problems, but it refuses to lock when I close the lid. I open the lid back up and, after a few seconds, it goes right back to where I left off. I opened up the settings app and went to Power. It did not show an option for suspending on lid close. The Gnome Tweaks app says that suspend on lid close is on. I Googled my problem and got a result saying to modify a configuration file. When I opened up the configuration file, the setting I was supposed to change was just how it was supposed to be:

#HandleLidSwitch=suspend

I have no idea what to do. If I switch to the KDE desktop, I don't have this problem, but Minecraft plays better on the default desktop. As I mentioned, I typically use this computer to play Minecraft, but I do have some sensitive files, not to mention all my passwords are saved. Is the problem that the login manager is that of KDE Plasma? I could really use some help here.

UPDATE: I found another page giving me instructions to create a completely new file. I am testing these instructions, and may not need this post anymore, but please still help if you know the answer.

UPDATE: The page didn't work.

UPDATE: I just discovered that my computer is suspending; it just doesn't lock. I am curious on why this is.

dlin avatar
in flag
Welcome to AskUbuntu! In case you found the solution to your problem, you can answer your own question as future reference for the community.
Tanner S. avatar
in flag
Thanks! I'll answer if what I found actually works.
Score:1
in flag

My login manager has been the one for KDE since I installed KDE. I never considered it, but Ubuntu probably just didn't recognize the login manager. If you need help with this problem, run this command:

sudo dpkg-reconfigure gdm3

Keep in mind, this answer is specific to computers running a login manager other than the built-in one.

Score:0
zw flag

Basically you have two possible "powermanager": Gnome's and systemd's. Gnome has successively removed more and more features over the years. But systemd's Logind is configurable.

Open as sudo:

sudo nano /etc/systemd/logind.conf

look for the line:

#HandleLidSwitch=suspend

Remove the leading hash, then your lid switch will suspend. You could replace "suspend" with "hibernate"(if permissions exists) or "poweroff"

Save the file. To ensure that the logind service will read the changes, log out and in again.

And yes: KDE as well as XFCE provide settings for this behavior via GUI of their own power managers.

To ensure that your screen is locked on suspend, search in "Activities" with "Lock":

1

"Lock Screen on Suspend" should do the job

Tanner S. avatar
in flag
Thank you. When I removed the hash, I still had the same problem as before. I also tried switching it to "hibernate", as you suggested. Once again, thank you for your answer.
kanehekili avatar
zw flag
I did this successfully on 20.04, since Logind overrules Gnomes behaviour. What happens if you execute `systemctl suspend`in a terminal?
Tanner S. avatar
in flag
My computer suspends, but doesn't actually lock. Hmm...
kanehekili avatar
zw flag
Ok, but that is another problem. So suspend might work, but your lock doesn't. It seems it boils down to: "how to activate lock when suspending" - which used to be the default in Gnome...
kanehekili avatar
zw flag
Concerning the lock, check my revised answer
Tanner S. avatar
in flag
"Automatic Screen Lock" and "Lock Screen On Suspend" are both on. In fact, all the sliders on this page are on. Thanks.
kanehekili avatar
zw flag
It even works on an Ubuntu 21.10 in a VirtualBox. Just checked it. The culprit must be somewhere else...
Tanner S. avatar
in flag
Maybe the culprit is the fact that my login manager is the built-in one for KDE?
Tanner S. avatar
in flag
Found the culprit. Thank you so much. Your suggestions may not have worked, but this conversation has helped me a lot in solving the problem. Once again, thank you.
kanehekili avatar
zw flag
Can't say - my policy is always to have exactly one DE on a system. Mixing systems in the early 2000's used to be fatal. I've never tried again ;-)
kanehekili avatar
zw flag
Great -I'd be interested in your findings.
Tanner S. avatar
in flag
I posted an answer below.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.