You are not logged in.

#1 2021-03-06 11:03:04

mattjg908
Member
Registered: 2021-03-06
Posts: 5

[resolved ]i3 and Arch, how to make screen lock after being idle

Thanks in advance for any help. I'm having a difficult time figuring out how to make my computer lock after being idle. I have Arch Linux and i3 window manager.

So far I have created /etc/systemd/system/i3lock@.service with this content:

   1 [Unit]
   2 Description=User suspend actions                         
   3 Before=sleep.target                                       
   4
   5 [Service]
   6 User=%I
   7 Type=forking
   8 Environment=DISPLAY=:0
   9 ExecStart=/usr/bin/i3lock -ef -c ffffff
  10 ExecStartPost=/usr/bin/sleep 1
  11
  12 [Install]
  13 WantedBy=sleep.target


I enabled it and it works when I close the lod of my laptop. However, I also want to lock the computer after idle. What's happening right now is that the computer goes to sleep after being idle but I can just press any button and I'm back in my session as if it were never idle (don't have to enter a password)

So, can anyone tell me if what I did to lock my computer when the lid closes is a typical or standard way of locking my computer when using Arch & i3? Also, can anyone tell me how I can tell my computer to lock when it's idle for x minutes instead of just sleeping?

Last edited by mattjg908 (2021-03-06 22:13:48)

Offline

#2 2021-03-06 16:04:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

Offline

#3 2021-03-06 18:12:43

mattjg908
Member
Registered: 2021-03-06
Posts: 5

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

Thanks for the reply Seth! So I:
-  $ sudo pacman -S xautolock
- vi ~/.config/i3/config/lock.sh
- add a line, `exec --no-startup-id xautolock -time 5 -locker 'lock.sh'`, save & reload i3

Works like a charm, thanks again!

Offline

#4 2021-03-06 20:29:02

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

Cool.
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Offline

#5 2021-03-06 21:45:13

mattjg908
Member
Registered: 2021-03-06
Posts: 5

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

thanks I will do that but wondered if you could give me a little more help. The command I pasted above locks the screen every 5 minutes, not after minutes of inactivity. Any thoughts?

I was in a text edior and not using a mouse so I guess it's not detecting key presses. Well anyway I'm going Google around as the general idea seems to have been satisfied- thanks again for the help.

Last edited by mattjg908 (2021-03-06 22:04:16)

Offline

#6 2021-03-06 22:13:31

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

Define "inactivity". Or rather your activity to prevent it (eg. moving the mouse or typing on the keyboard?)
Looking at the command, is ~/.config/i3/config in your $PATH? Ie. are you sure it's xautolock that triggers this at all?

Key presses should™ count, bu I'm not sure whether _NET_WM_USER_TIME updates are relevant.

Last edited by seth (2021-03-06 22:15:53)

Offline

#7 2021-03-06 22:21:05

mattjg908
Member
Registered: 2021-03-06
Posts: 5

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

thanks for the follow-up Seth. I updated the title of this post to include [resolved ] but is there some way to mark you as the resolver?

In response to your questions:
- I define activity as not touching the mouse nor keyboard nor (un)plugging peripheries
- Opened VIM and was editing a file and the screen locked. However, I restarted i3 and this doesn't seem to happen any more smile
- ~/.config/i3/config isn't in my path but the command I put in there is (/usr/local/bin/lock.sh) and my i3 configs do work so I'm not sure how it works but that config file is loaded and does have an effect on my i3
- great point! No, I'm not sure xautolock is/was triggering it

Thanks again for the follow-up questions! I did reload my i3 and ti seems to be working as intended so I think this is fully resolved. I really appreciate the help!

Last edited by mattjg908 (2021-03-06 22:21:37)

Offline

#8 2021-03-06 22:26:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,552

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

but is there some way to mark you as the resolver?

No, and it's not required or relevant either. The indicator is really just for others, not my ego smile

I restarted i3 and this doesn't seem to happen any more

We'll then assume a heisenbug. Feel free to revisit the topic in case the behavior re-appears as non-deterministic.

Offline

#9 2021-03-06 22:33:21

mattjg908
Member
Registered: 2021-03-06
Posts: 5

Re: [resolved ]i3 and Arch, how to make screen lock after being idle

cool, well I have to say I am loving Arch and I do appreciate the forum's help smile

Have a great weekend

Offline

Board footer

Powered by FluxBB