1

Topic: sleep mode after a few minutes of inactivity

Is there a simple way, like a bash script or something similar, to make the computer go into sleep mode after a few minutes of inactivity?

2 (edited by anthk 2025-01-22 14:43:24)

Re: sleep mode after a few minutes of inactivity

You can do it with xidle, doas and zzz

 
xidle -timeout 120 -program 'doas zzz' & 

For easyness, you can place that at ~/.xinitrc, above the  last line you would put to start the window manager, such as 'exec icewm-session': 

 

xidle -timeout 120 -program 'doas zzz' & 

exec icewm-session
 

 

You need to add yourself to the 'power' group.

3

Re: sleep mode after a few minutes of inactivity

Thank you very much, I will try it

4

Re: sleep mode after a few minutes of inactivity

After several attempts I managed to get it working.

xidle -program "/usr/bin/doas zzz" -timeout 7200 &

5 (edited by gnu 2025-01-24 01:16:48)

Re: sleep mode after a few minutes of inactivity

Xidle has a problem when the machine wakes up, after a few seconds it goes back to sleep mode, so I found this solution with Xautolock.

xidle -program "/usr/bin/xtrlock" -timeout 300 &
xautolock -time 30 -locker "/usr/bin/doas zzz" -detectsleep &