Lock on suspend

i3
elogind

#1

I just installed Manjaro with OpenRC and i3 window manager. I want my screen to lock whenever I suspend. in ~30% of cases the screen doesn’t lock. And in some cases my computer wakes up from suspend, then it is unlocked for a few seconds before it locks. This seems like a huge security problem. I also got the problem that my screen locks after 10 minutes of inactivity and I cannot figure out how to turn that off, I guess I kill two birds with one stone here.

I wanted to solve this problem and everywhere I read about dm-utils which apparently offers scripts which I could edit. So I guessed I could just edit these scripts and lock before suspend. (so far the plan) Turns out I do not have dm-utils and I can also not install it because it conflicts with elogind. I couldn’t find any info how or if I could do something similar with elogind. I am really confused because the OpenRC wiki page of manjaro says “To suspend and hibernate via the command line, pm-utils can be installed.” Also the gentoo wiki says “elogind is the systemd project’s logind”, but this isn’t systemd.

I would like my screen to lock when I suspend. Does anybody have any ideas?


#2

Openrc uses “elogind” which in turn uses “loginctl” to see all commands for this use

loginctl -h

in a terminal

Just checked

loginctl lock-session

works


#3

Yes thanks that works. But this doesn’t solve my problem that my screen sometimes doesn’t lock when I suspend.


#4

Why not combine the two commands in a shortcut or harder add lock-session to the suspend command?


#5

I now moved to KDE.

But when I was using XFCE, I ended up putting in my .xsession:

xautolock -time 5 -locker "xlock -nolock -mousemotion -mode bouboule -size 50"&

you can try by removing -nolock:

xautolock -time 5 -locker "xlock -mousemotion -mode bouboule -size 50"&

obvisouly you have to install those 2 suckless proggies: xlockmore xautolock

KDE or Maté are perfect in that matter out of the box.


#6

Yes, but this is exactly my question. Where are these scripts. I can only find information about pm-utils but I cannot install pm-utils.


#7

I am not using XFCE I am using i3.


#8

You can’t use pm-utils in openrc!

loginctl lock-session && loginctl suspend

works


#9

packages xlockmore & xautolock can be installed with pacman - not in AUR.

it is alternate screensaver (quite nice). It should work with any DE.


#10

OK good to know. But are you sure about this because here it clearly says install it: https://wiki.manjaro.org/index.php?title=OpenRC,_an_alternative_to_systemd#Suspend.2FHibernate

Anyways, I am still looking where I could insert this. Yes you can suspend and lock from terminal with this command. But it doesn’t work like this, for example, when I close my notebook. I would just like to know what gets executed when I click suspend or when I close my laptop.


#11

This as a script

#!/bin/bash
loginctl lock-session && loginctl suspend

Make it executable point a menu entry to it
hit this before you close the lid
If closing the lid suspends any way you only need the first pat of the script


#12

In case you are serious and not just trolling: I do not want to execute anything. I just want to fix “suspend”.


#13

The page you linked said that plymouth can’t be used with openrc.
Maybe pm-utils can be used, but pm-utils is largely deprecated.

I understand that you want your minimalist desktop using a refusenik init system to operate just like the big boys. But you are going to have to do some digging on this because it is no longer mainstream knowledge.

A system should never awake from suspend by itself, and if it does it usually is an indication that some hardware wake feature (wake-on-mouse, wake-on-lan, etc) is still enabled and operational. (Check your bios).
Some systems also have wake-on-battery capability to tell the system to wake up and hibernate - called emergency-hibernate, when the battery gets too low.


#14

Ok, pretty lame response. He was trying to be helpful.

Suspend (closing the lid) DOES EXECUTE SOMETHING. It executes a task that initiates suspend to ram, which essentially turns off almost everything except ram refresh cycles. It is always software controlled.

The lid closure is just a switch that the OS senses.

@robinw0800 was suggesting you create that script and wire it in where ever lid close is detected. This is all managed by text files somewhere in your system, probably in /etc . Differs slightly by DE.


#15

The system does not wake up on itself. I wake it up. That’s not the issue. The issue is that I wake the system up but the screen is not locked. (or does only lock shortly after)

Also I do not need all that functionality. I just want my system to properly suspend.


#16

Yes! My question is: what exactly happens when I suspend. If I knew this I could debug the problem.


#17

Start reading here
https://wiki.archlinux.org/index.php/Power_management

It covers a bunch of the things you have mentioned.


#18

That link is “systemd” and his problem is “openrc” not sure in this case it is much use


#19

Interesting analogy. For the record, refusenik didn’t originally mean those who refuse to go along.

The original usage referred to those who are refused, denied their freedom of mobility by a dictatorial (and dare I say Red) authority.

</ semantics>


#20

Thanks, but nope no help. Already read that. I am using OpenRC and I am seriously thinking about switching to systemd because of that problem.