google / xsecurelock

X11 screen lock utility with security in mind
Apache License 2.0
863 stars 65 forks source link

How to do: (lock -> blank screen -> turn off screen -> wait for two hours -> suspend device) #170

Open zefr0x opened 1 year ago

zefr0x commented 1 year ago

I'm trying to do this:

flowchart TD
    A(Lock Activated) --> B[Show Blank Screen]
    B --> C{Wait for 10s}
    C --> |Activity| D[Prompt to Unlock]
    C --> |No Activity| E[Turn off Screen]
    E --> F{Wait for 2h}
    F --> |Activity| GA[Stop Timer]
    F --> |No Activity| H[Suspend Device]
    H --> |Turn on Device| D

    GA --> GB[Turn on Screen]
    GB --> D

My config: scripts/lock.sh

My screen saver script: scripts/saver_sleep_after_time

My xss-lock launch: .config/i3/config


What I concluded is happening with me is that as soon as XSECURELOCK_BLANK_TIMEOUT ends my screen will be turned off, but also the saver_sleep_after_time script will stop working, and the 2h timer for suspending will not work.

If I disabled XSECURELOCK_BLANK_TIMEOUT my screen will be always working which is a problem too.

Is there any solution for that?

akino512 commented 1 year ago

I don't know how to set suspend, but you can try the following to set locks and the screen turn off. A simple style may be like this:

xset dpms 0 0 60  // wait 60s to turn off screen
xset s 30 // wait 30s to lock device
xss-lock -l -- xsecurelock &
zefr0x commented 1 year ago

I don't have problems with this part.

xset dpms 0 0 60 // wait 60s to turn off screen

I'm already using this to trigger xss-lock.

xset s 30 // wait 30s to lock device

This will just dim my screen using /usr/lib/xsecurelock/dimmer preparing to it's lock, xsecurelock will handle things aftart that.


My problem is with xsecurelock's screen saver part. After locking the screen it should start working as a timer to suspend my device after some time, and be killed with any activity (e.g. keyboard clicked, mouse moved).

But what is happening with me is that xsecurelock's screen saver will not work directly when my screen is locked, it will only work if I did an activity after locking my screen (without unlocking it) then keep it idle again.

I want xsecurelock's screen saver to work directly after locking my screen.

useredsa commented 11 months ago

The second exec of saver_sleep_after_time is not going to get executed because the shell will get replace with the sleep command.

I would also be interested in this state diagram.

akino512 commented 4 months ago

@zefr0x Keep "xss-lock" running and run "xautolock". like this:

xss-lock -l -- env XSECURELOCK_BLANK_TIMEOUT=10 xsecurelock
xautolock -time 60 -locker "systemctl suspend" -detectsleep

(xautolock seems to have a timer limit of up to 1 hour)