You are not logged in.

#1 2013-11-04 12:05:24

danilo
Member
From: Switzerland
Registered: 2010-12-10
Posts: 25
Website

[solved] Inactivity timeout with systemd

Is it possible to start a service after a specified time of inactivity?

I created a service that calls my screen locker automatically on suspend:

[Unit]
Description=Lock the screen on resume from suspend

[Service]
User=danilo
Environment=DISPLAY=:0
ExecStart=/usr/local/bin/slock

[Install]
WantedBy=suspend.target

Can I also start this service after e.g. 2 minutes of inactivity?

If not – I don't really like xscreensaver, is there a more lightweight alternative?

Last edited by danilo (2013-11-19 10:02:06)


"Freedom is the freedom to say that two plus two make four. If that is granted, all else follows." - George Orwell

Offline

#2 2013-11-04 20:35:25

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] Inactivity timeout with systemd

I use xautolock.  It has served me well for over a year or so.  Basically, anytime you call suspend (with systemctl) it will go through the process of activating the suspend.target.  So anything hooked into the suspend.target.wants is going to run with it.

I use this:

xautolock -time 12 -locker "systemctl suspend" -detectsleep

The last "-detectsleep" part is an attempt to avoid having it double suspend.  That is, it wakes up and thinks that oh, the time is now X minutes later and there was no activity... sooo suspend now!  But I also have a small script in /usr/lib/systemd/system-sleep that stops xautolock and then restarts it on wake... so I have a feeling that my -detectsleep addition is fairly worthless.

Offline

#3 2013-11-19 10:01:32

danilo
Member
From: Switzerland
Registered: 2010-12-10
Posts: 25
Website

Re: [solved] Inactivity timeout with systemd

A bit late, but thanks a lot! That worked perfectly smile

Here's a systemd service file, for people that want to use it too: https://github.com/dbrgn/dotfiles/blob/ … ck.service


"Freedom is the freedom to say that two plus two make four. If that is granted, all else follows." - George Orwell

Offline

Board footer

Powered by FluxBB