How to lock and suspend when lid closed


I come from manjaro as I wanted something more “vanilla”, so far my impressions are good.
I intend to run Archlabs on my laptop (XPS 13 9370) and the only thing bothering me is that while I close the lid suspend works fine but the session doesn’t get locked and I can’t seem to find a way how to suspend AND lock when closing the lid.
I think this is a crucial function when using Archlabs on a laptop, so I am kind of surprised that this isn’t setup OOB.


What I’m about to show you works for me quite well (YMMV - and in the end, may not be what you are looking for).

I installed xsceensaver also since I actually want a screen saver to kick in.

In my i3 config I have these 2 lines.

exec --no-startup-id xscreensaver -no-splash &
exec --no-startup-id xautolock -time 30 -locker “i3lock -c 000000”

You will need to run xscreensaver to set the parms you want. For example, you may only want one screen saver opposed to the default of random. You will also want to set the time outs too.
In my .xscreensaver file, I have these set for my default timings:

timeout: 0:15:00
cycle: 0:10:00
lock: True
lockTimeout: 0:00:00
passwdTimeout: 0:00:30
splash: false

So basically, the screensaver kicks in in 15 mins. The lock timeout is set to 0 (that means it requires a password once the screensaver kicks in. And of course, once you are prompted for
the password via xscreensaver, you have 30 seconds before it goes back to the screensaver.
and lastly, I don’t want xscreensaver to display the splash screen (because it will give someone the ability to change the screensaver settings at that point).

The second line I have in the i3 config simply sets the auto-lock color to a black screen. I have a feeling that that line is just left over and I never removed it so it may not be needed.

In my case, once I close the lid, the lappy hibers and when I open it - I am prompted for a password.

Give it a shot, tweak as you need to and in the end, it’s all about what you want and how you wan to do it. This is just what I have done and works well for me.

As an alternative, lots of folks have xfce4-power-manager installed and control all of the settings via xfce4-settings-manager too


Thanks for the answer! Unfortunately it is not what I am looking for (you predicted it)… what I am looking for is some way to combine suspend with locking.

As suspend without a locked session is pretty useless imo. Is there no way I can change some config where suspend automatically triggers the default locker of Archlabs?
So that I can just close the lid instead of pressing [STRG + ALT + L] first to lock the session and then close the lid to suspend it.

(I also tried the xfce4-power-manager but it didn’t do anything)

I really want to get this working before I take a deep dive into the configs, so I know it’ll be worth the time :slight_smile:

See my update about the xfce modules. THIS will do what you want it to. Im surprised that the power-module did nothing for you. Hmmm.

Is there anything else to do besides just installing xfce4-power-manager? Because it doesn’t matter what I set in the settings nothing happens.
“When laptop lid is closed” is set to “Lock screen” and when I close the lid, nothing happens, not even suspend is working while xfce4-power-manager is running…

That’s odd. When you installed the XFC4-P-M, where you told it was going to install some dependencies (assuming you may have installed via pamac-manager) and you should have also been prompted to start the corresponding service when launched.

I suspect these ought to be running for you.
17830 ? Ssl 0:00 xfce4-power-manager
17835 ? Ssl 0:00 /usr/lib/upowerd

I simply installed it via terminal and pacman, no dependencies were installed. However I also tried to install it via the al-Hello script but the result is the same. Weird is also that although I chose to install pamac in the script it’s not installed. I’ll try and install the xfce4-p-m via aur.

Edit: Nope, installed pamac, installed xfce4-p-m with it same result.

And of course as a reference (but you probably knew that anyways) :wink:

Already changed what should be changed in /etc/systemd/logind.conf when “HandleLidSwitch=suspend” is set to anything else than “suspend”, again, nothing happens…

Not sure on what other info I can provide. I too am kinda at a loss. Sorry. Hoping other folks here might have noticed something I may have missed.


No problem. I tried most of what I found googling so far nothing seems to work, hope a dev can think of something.

1 Like

Try this method:

Alternatively, I think installing and configuring LightDM will automagically lock the screen after resuming from suspend or hibernate.

1 Like

I already tried that method, installed slock, configured the .service file and enabled it via systemctl and it does nothing.
I also already have lightDM installed, doesn’t matter what I configure suspend and lock doesn’t want to work.

Is there no way I can simply chain the [STRG+ALT+L] shortcut to the suspend function? Honestly seems easy but I can’t figure out how to.

Please post your .service file here, perhaps you made a mistake.

How exactly did you enable it?

Did you check the journal to see if the file was activated and why it failed?

If you already have LightDM installed then please explain how you have attempted to configure that.

This will show us all of your enabled unit files:

systemctl list-unit-files --state=enabled

I think the ArchLabs autologin unit file needs to be disabled and set as the default for LightDM to work but I may be wrong.

I’m such an idiot, I misspelled my user name in that .service file :zipper_mouth_face:

Now it actually does work! Is the ~0.5-1 sec delay between waking up and locking the screen normal?
Is it possible to trigger the Archlabs locker with that .service file? It’s just an astatic thing as I prefer the Archlabs locker look over the look of slock…

Thanks for your help so far!

No idea, sorry, I don’t use a screen locker.

Only one way to find out :slight_smile:

I don’t get how people can live without screen lockers :open_mouth:

What is the name/command of the screen locker Archlabs uses? (I’m new to Openbox/i3 etc)

I don’t know but slock is probably the best there is (IMO) so why not use that?

I believe it’s i3lock fancy

1 Like