View previous topic :: View next topic |
Author |
Message |
reikdas Apprentice
Joined: 27 Nov 2018 Posts: 238
|
Posted: Fri Jan 04, 2019 12:57 pm Post subject: i3 - Lock screen on suspend |
|
|
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 |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9677 Location: almost Mile High in the USA
|
Posted: Sat Jan 05, 2019 12:45 am Post subject: |
|
|
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/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
reikdas Apprentice
Joined: 27 Nov 2018 Posts: 238
|
Posted: Sat Jan 05, 2019 5:33 am Post subject: |
|
|
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 |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9677 Location: almost Mile High in the USA
|
Posted: Sat Jan 05, 2019 6:27 am Post subject: |
|
|
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/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Muso Veteran
Joined: 22 Oct 2002 Posts: 1052 Location: The Holy city of Honolulu
|
Posted: Sat Jan 05, 2019 2:52 pm Post subject: |
|
|
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 :
You can adjust the time for timeout and suspend with the following (using 15 minutes in seconds)
The two zeros represent timeout & suspend. _________________ "You can lead a horticulture but you can't make her think" ~ Dorothy Parker
2021 is the year of the Linux Desktop! |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9677 Location: almost Mile High in the USA
|
Posted: Sat Jan 05, 2019 4:41 pm Post subject: |
|
|
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/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
reikdas Apprentice
Joined: 27 Nov 2018 Posts: 238
|
Posted: Sun Jan 06, 2019 6:25 am Post subject: |
|
|
Muso wrote: | For reikdas, to find out more about the suspend, run :
You can adjust the time for timeout and suspend with the following (using 15 minutes in seconds)
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 |
|
|
Hu Moderator
Joined: 06 Mar 2007 Posts: 21595
|
Posted: Sun Jan 06, 2019 5:17 pm Post subject: |
|
|
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 |
|
|
|