You are not logged in.

#1 2016-02-09 16:19:53

rking
Member
Registered: 2015-11-23
Posts: 16

using xautolock and i3lock to lock/suspend after inactivity

hi,

am using i3wm and have added the following lines to my ~/.i3/config:

#lock screen with i3lock/xautolock

exec  bindsym Ctrl+Mod1+Delete exec xautolock -locknow 

which successfully locks the screen


i'm also looking to lock the screen after 5 min of inactivity, then suspend 10min after that, and ideally 10 min after i start i3lock (whether via timeout due to inactivity or manual call as above).  I have tried the following line:

exec_always --no-startup-id xautolock -time 5  -locker "i3lock -c 272d2d  && sleep 1"-killtime 10 -killer "systemctl suspend"  -detectsleep 

it activates i3lock after 5 min of inactivity properly, but after 10 min the screen turns off, but no suspend.

a temporary solution for me was to simply do the following in ~/.i3/config:

 -- exec_always --no-startup-id xautolock -time 5  -locker "systemctl suspend" 

with the following systemctl service enabled to start i3lock on wake from suspend

[Unit]
Description=i3lock
Before=sleep.target

[Service]
User={Inserted my User}
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock -c 272d2d

[Install]
WantedBy=sleep.target

it works fine as expected, but this is not really the situation i want.  I have a feeling it is due to one of the three following issues:

1) xset dpms
2) something weird with the killtime and killer options with xautolock in my above attempt
3) maybe it's not suspending as i3lock/xautolock stops the suspend

I don't really know where to start with 2 and 3 but the following is the output of xset -q:

Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  660    repeat rate:  25
  auto repeating keys:  00ffffffdffffbbf
                        fadfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  600
Colors:
  default colormap:  0x5f    BlackPixel:  0x0    WhitePixel:  0xffffff
Font Path:
  /usr/share/fonts/misc/,/usr/share/fonts/TTF/,/usr/share/fonts/OTF/,/usr/share/fonts/Type1/,/usr/share/fonts/100dpi/,/usr/share/fonts/75dpi/,built-ins
DPMS (Energy Star):
  Standby: 600    Suspend: 600    Off: 600
  DPMS is Enabled
  Monitor is On

journalctl -b -u systemd-suspend gives nothing useful:

Feb 09 10:05:10 myhostname systemd-sleep[9167]: Suspending system...
Feb 09 10:21:19 myhostname systemd[1]: Started Suspend.

can anyone give me a hand in trying to sort this out?  can you have two xautolock timers running at the same time?


thanks in advance!

Offline

#2 2016-12-08 16:45:53

bwv549
Member
Registered: 2013-12-13
Posts: 14

Re: using xautolock and i3lock to lock/suspend after inactivity

I'm also interested in implementing this exact same thing: I also use i3wm and i3lock with xautolock and I now want to implement "systemctl suspend" as the xautolock killer.

To be clear, the implementation you show below works, but you are annoyed that you have to use two separate xautolock calls (and annoyed that you have to make a systemctl service file for i3lock?) to get the behavior you want, right?

Have you found anything better?  I will report back if I find anything better/simpler.

Offline

#3 2017-01-24 02:49:34

bwv549
Member
Registered: 2013-12-13
Posts: 14

Re: using xautolock and i3lock to lock/suspend after inactivity

xss-lock might be a good way to ensure i3lock starts up after suspend.  (The example it gives in that wiki page is of i3lock)

Offline

#4 2017-01-24 03:08:31

bwv549
Member
Registered: 2013-12-13
Posts: 14

Re: using xautolock and i3lock to lock/suspend after inactivity

I am now running these lines on startup (my i3 config calls out to a script that calls a script with these lines):

xautolock -time 5 -locker fuzzy_lock -notify 20 -notifier 'xset dpms force off' &
xautolock -time 7 -locker "systemctl suspend" &

So far, I haven't had any issues with this (i3lock fires up correctly after suspend [without xss-lock]).

Offline

#5 2022-10-16 13:01:19

pc00per
Member
Registered: 2022-05-22
Posts: 14

Re: using xautolock and i3lock to lock/suspend after inactivity

bwv549 wrote:

I am now running these lines on startup (my i3 config calls out to a script that calls a script with these lines):

xautolock -time 5 -locker fuzzy_lock -notify 20 -notifier 'xset dpms force off' &
xautolock -time 7 -locker "systemctl suspend" &

So far, I haven't had any issues with this (i3lock fires up correctly after suspend [without xss-lock]).

This will not work now, as you can't run two instances of xautolock. Only one is allowed. The correct syntax would be

exec --no-startup-id xautolock -time 15 -locker 'systemctl suspend' -notify 600 -notifier 'i3lock | xset dpms force off' &

Locks after 5 minutes (including screen off), sleeps after 15 minutes.

Offline

#6 2022-10-16 17:04:22

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,774

Re: using xautolock and i3lock to lock/suspend after inactivity

pc00per, that looks like valid information, but as it has been coming up on six years, I am going to go ahead and close this thread.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB