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.

6 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.

For anyone in the future who screws it up by setting it to 10 seconds and not 10 minutes on a CoreBoot+Heads device… here’s something you can try!

Situation

  • You accidentally set it to shutdown on idle with 10 seconds. :upside_down_face:
  • You can’t login because it’ll immediately shutdown before you see the login screen.
  • Heads probably soft-locked (DA lockout mode) your TPM due to too many reboots.
What's DA Lockout Mode
  • Triggering a DA lockout: If the system is abruptly or improperly shut down multiple times, or if a user fails to enter the correct passphrase too often, the TPM’s internal counter for failed authorization attempts can be triggered.
  • Preventing key unsealing: Once in DA lockout mode, the TPM will block attempts to unseal keys, even with the correct passphrase, to protect against potential dictionary attacks. The system will then be unable to unlock the encrypted disk and will fail to boot.
(IMG) Shutdown on boot

Resolution

  1. If the device is soft-locked, turn it off and wait 30 minutes.

  2. Boot up the device.

  3. Press any key when prompt Automatic boot in 5 seconds unless interrupted by keypress...

  4. Arrow down and select Options -->

  5. Go down and select Exit to recovery shell

  6. Enter:kexec-select-boot -b /boot -a systemd.mask=systemd-logind.service

  7. Your device will now boot, ask for the encryption passphrase, and boot into Qubes at the login screen without automatically shutting down.

  8. FIX YOUR /etc/systemd/logind.conf !!

(IMG) Example of the error in my ways

Special Thanks

I would like to personally thank @Insurgo, @arraybolt3, and @marmarek on the Qubes OS Matrix channel for the immense help! :star2:

This was a great teaching moment for myself as this screw up helped me learn more about Coreboot+Heads, the Linux kernel, and Qubes OS!

(IMG) Bonus: I also managed to get a little achievement

4 Likes

LOL - well done recovering from this little mistake! :laughing:

1 Like