Qubes-OS idle shutdown timer and shutdown when laptop lid closed

Is there a way to make it so that
when I close my laptop lid Qubes shuts down
and when the laptop is idle for a set time it automatically shuts down
I enjoy the benefits of Lux encryption when I am putting my laptop at rest and do not use the screensaver

I did not see this anywhere and could not figure out the necessary combination of settings to make both of these things work despite the “power manager”/“screensaver” settings for dom0
It seems as if the power manager and the screensaver do not actually power off the machine based on the settings.

I didn’t try this on Qubes, but in general it works on systemd-based systems:
Edit /etc/systemd/logind.conf and add:

IdleAction=poweroff
IdleActionSec=30min

(replace 30min with your preferred interval, of course)

EDIT and Update #1: it works on my heavily used and modded 4.1.2 installation. Will test on 4.2rc4.
EDIT and Update #2: works on 4.2rc4 too.

The behavior is a little weird: I had the IdleActionSet=10min, and the (stock, blanking, locking) screensaver at 10 minutes too. The laptop shut itself down after 20 minutes! Like it started the Idle timer when the screensaver kicked in and locked the screen.

5 Likes

I set that. Is there a way to make it so that when the lid is closed the computer shuts down?

nvm I see now in logind.conf there are commented out commands that are useful thank you!

1 Like

No worries! my pleasure.

Update: works on 4.2rc4 too.

The behavior is a little weird: I had the IdleActionSet=10min, and the (stock, blanking, locking) screensaver at 10 minutes too. The laptop shut itself down after 20 minutes! Like it started the Idle timer when the screensaver kicked in and locked the screen.

Hello everyone,

I am also trying to set up my laptop to switch off automatically after a certain period of inactivity.

But now it doesn’t work for me.
I edited the logind.conf file with nano, i.e. wrote in the first two lines as described, to test with 5 min. I left all the lines with the # in the file.
Restarted the laptop and now I’m waiting. Still on after an hour. Anyone have any idea what I have done wrong?

[irrelevant comment retracted]

if this is also in the file, in my case there is a “#” in front of everything. So that should mean that everything is inactive. A screen saver is not set at all.

[irrelevant comment retracted]

1 Like

Update: I can’t make this work in R4.2 any more. Same laptop that was working with R4.2rc4.
The culprit seems to be something related to xscreensaver, which is set to “blank only” but never actually manages to put the display to sleep. The password box pops up after 10s, times out, then appears again and so on. No USB devices connected. Very weird, I will investigate further.

2 Likes

Did you have any luck? I’ve been having problems using this ever since R4.2 came out as well, so I was wondering if anyone found a fix.

Oh yes. The (stupid) reason for which it was not working was my fault :blush: … I inadvertently had “Presentation Mode” switched ON.
After turning that setting OFF, the method works again, in the way described: it will wait for the system to become Idle (when the screensaver starts), then, if the computer stays idle, after the time specified with IdleActionSec= it will perform the action specified with IdleAction= .

Edit: rephrased for clarity.