I would like my screen to lock automatically when I close the lid (or otherwise trigger a suspend), but only if I leave it closed for a certain amount of time, e.g. 5 minutes. That is, if I close the lid and then open it 1 minute later, I'd like the screen to not be locked, but if I open the lid 10 minutes later, it should be locked. Is there a way to set this up in Ubuntu (GNOME)?
I see several similar questions, but none that describe what I'm looking for. I still want the laptop to suspend immediately when the lid closes, I just don't want it to lock unless the lid stays closed for a certain amount of time. (Ideally it would obey the same "Automatic Screen Lock Delay" setting that is used while the lid is open.)
One way I could imagine implementing this is to run scripts at suspend and wake. The suspend script would just record a timestamp for the suspend, and the wake script would check to see how old the timestamp is and decide based on that whether to lock or unlock the screen. However, I assume I would have to set up these scripts to run as my user (i.e. not root) and they would need to be able to access my existing login session (presumably via some environment variables?), so I'm not if this is possible to implement.
/etc/acpi/
? – Pablo Bianchi Nov 08 '21 at 16:33