Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
i3 - Lock screen on suspend
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
reikdas
Apprentice
Apprentice


Joined: 27 Nov 2018
Posts: 238

PostPosted: Fri Jan 04, 2019 12:57 pm    Post subject: i3 - Lock screen on suspend Reply with quote

This is the locking line in my i3 config -
Code:
exec --no-startup-id xautolock -time 15 -locker "~/.config/i3/fuzzy_lock.sh" &


The fuzzy_lock.sh script -
Code:
#!/bin/sh 
scrot /tmp/i3lock.png 
# Lock screen displaying this image.
~/.config/i3/i3lockmore/./i3lockmore --blur --image-fill /tmp/i3lock.png 
# Turn the screen off after a delay.
sleep 60; pgrep ~/.config/i3/i3lockmore/./i3lockmore && xset dpms force off


i3lockmore - https://github.com/SammysHP/i3lockmore

It works - Locks after having my computer inactive for 15 minutes.

If I wake my laptop from suspend before 15 minutes has passed, there is no lock. Otherwise there is a lock but my fuzzy_lock.sh script does not get executed. I want my laptop to be locked whenever I wake my laptop from suspend and also execute the fuzzy_lock.sh script so I get the blurred screenshot as a background.

Init - openrc
_________________
[19:18] <@NeddySeagoon> Gentoo has an installer. Just like other distros. Go to the bathroom, look in the mirror. You will see the Gentoo installer :)
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Sat Jan 05, 2019 12:45 am    Post subject: Reply with quote

Even your current solution has a race condition in it, though no normal human can beat that race...

This is why all these desktop environments have all this infrastructure to ensure your desktop gets locked. Ultimately you have to manually run the lock script just before suspend, and it will solve the case for both before and after 15 minutes. So the question is: how are you telling the computer to suspend? Can you add a script into that suspend run path?

If you're just echoing ram to /sys/power/state you should write a script that wraps it. Just do an immediate screen lock and then suspend after perhaps a few seconds to close the race on resume. If you're depending on an ACPI event like a button press or lid close, you'll need to play with that script, which is harder as the ACPI script runs as root.

This functionality is usually baked into most normal desktop environments and one of the reasons why they have so much code, and keeps all that code running as the user until it initiates the kernels suspend...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
reikdas
Apprentice
Apprentice


Joined: 27 Nov 2018
Posts: 238

PostPosted: Sat Jan 05, 2019 5:33 am    Post subject: Reply with quote

eccerr0r wrote:
If you're just echoing ram to /sys/power/state you should write a script that wraps it. Just do an immediate screen lock and then suspend after perhaps a few seconds to close the race on resume. If you're depending on an ACPI event like a button press or lid close, you'll need to play with that script, which is harder as the ACPI script runs as root.


Is there a way to figure out how my laptop suspends?
_________________
[19:18] <@NeddySeagoon> Gentoo has an installer. Just like other distros. Go to the bathroom, look in the mirror. You will see the Gentoo installer :)
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Sat Jan 05, 2019 6:27 am    Post subject: Reply with quote

You'll have to figure out how the suspend is occurring... I'm not familiar with i3, but there must be some program that does the timeout suspend. That program will need to be the program that deals with the locking, not xautolock. Hopefully it's not BIOS or something, then you'd have to deal with ACPI scripts...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Muso
l33t
l33t


Joined: 22 Oct 2002
Posts: 968
Location: The Holy city of Honolulu

PostPosted: Sat Jan 05, 2019 2:52 pm    Post subject: Reply with quote

i3 doesn't handle the suspend, that's X. I disable it myself, as I don't care for suspend.

Code:
xset s off
xset -dpms


I just use i3lock when I step away.

For reikdas, to find out more about the suspend, run :

Code:
xset q


You can adjust the time for timeout and suspend with the following (using 15 minutes in seconds)

Code:
xset dpms 0 0 900


The two zeros represent timeout & suspend.
_________________
Time is a great teacher, but unfortunately it kills all its pupils.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Sat Jan 05, 2019 4:41 pm    Post subject: Reply with quote

That's the X11/DPMS screen suspend, not the system/ACPI suspend. There must be something else triggering the system suspend.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
reikdas
Apprentice
Apprentice


Joined: 27 Nov 2018
Posts: 238

PostPosted: Sun Jan 06, 2019 6:25 am    Post subject: Reply with quote

Muso wrote:
For reikdas, to find out more about the suspend, run :

Code:
xset q


You can adjust the time for timeout and suspend with the following (using 15 minutes in seconds)

Code:
xset dpms 0 0 900


The two zeros represent timeout & suspend.


DPMS (Energy Star):
Standby: 600 Suspend: 600 Off: 600
DPMS is Enabled
Monitor is On

Are the 0 and 0 for Standby and suspend? and 900 for off?
How do I trigger my locking script with this information?
_________________
[19:18] <@NeddySeagoon> Gentoo has an installer. Just like other distros. Go to the bathroom, look in the mirror. You will see the Gentoo installer :)
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13496

PostPosted: Sun Jan 06, 2019 5:17 pm    Post subject: Reply with quote

According to the manual (man xset), yes, that script sets the X server's DPMS usage to standby=0 (disabled), suspend=0 (disabled), off=900 (after 15 minutes of no activity). According to Xorg configuration hook for unblank screen (as found through a Google search for xorg dpms script), you can be notified of screen blank/unblank events to run your lock tool. You could also use a dedicated screenlocking tool, such as xscreensaver, that handles timing on its own.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum