google / xsecurelock

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

Turn off screen backlight instead of a blank screen #93

Open cubetastic33 opened 4 years ago

cubetastic33 commented 4 years ago

Is it possible to make the actual backlight turn off instead of showing the blank screen that comes before the auth screen? Also, is it possible to show an image instead of this blank screen?

divVerent commented 4 years ago

Cool idea; anyone know an API to do that on X11 though?

nerosun64 commented 4 years ago

Cool idea; anyone know an API to do that on X11 though?

I don't know about API but you can use xset dpms force off

qdzhang commented 3 years ago

To turn off screen backlight, you can use this option passing by environment variables:

export XSECURELOCK_BLANK_DPMS_STATE=off

It specifies which DPMS state to put the screen in when blanking.

cubetastic33 commented 3 years ago

is that not the default setting?

divVerent commented 3 years ago

Yes, by default xsecurelock uses the same API as "xset dpms force off" would be using.

But I understand that there are probably some systems where this does nothing, but e.g. xbacklight or brightnessctl can turn off the backlight.

If anyone can confirm that they have a system where "sleep 1; xset dpms force off" does not do anything to the backlight (the sleep is there so your enter key release event comes before the turning off), but brightnessctl and/or xbacklight work, I think I'll implement that support into xsecurelock - but "just because it might help" is probably not worth doing. In particular as the brightnessctl/xbacklight methods come at a risk: if xsecurelock then crashes, the screen stays dark.

On Fri, Jan 29, 2021 at 6:47 AM aravk33 notifications@github.com wrote:

is that not the default setting?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/xsecurelock/issues/93#issuecomment-769757863, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB5NMDD7CFYDKEY7VBBN23S4KN3VANCNFSM4KDZJEMQ .

cubetastic33 commented 3 years ago

Right, but that wasn't what my initial issue was about though - by default xsecurelock does turn off screen backlight for me if I don't type anything for a while in the lockscreen. What I was talking about is the screen that shows up before I press a key to type the password. If I'm using a screensaver module like mpv, then instead of the black screen, mpv shows up - but when no screensaver module is used, it shows a black screen with the backlight turned on, and pressing a key brings up the dialog where we type our password. I was wondering if it was possible to turn of the backlight instead, and pressing a key brings up the dialog.

divVerent commented 3 years ago

Ah, so you just want the backlight turned off instantly.

That is currently almost supported - you could just create your own saver script (e.g. make a copy of saver_blank but add a line with "xset dpms force off" right before the "exec sleep 86400" line) - but the reason why it's not done this way right now is that instantly blanking is annoying with many monitors that take multiple seconds to get out of blanked state.

If there's more demand for this to justify a dedicated setting, I can of course also make this an official feature, bu would you already be happy with doing this minor change to saver_blank on your end?

On Fri, Jan 29, 2021 at 10:34 PM aravk33 notifications@github.com wrote:

Right, but that wasn't what my initial issue was about though - by default xsecurelock does turn off screen backlight for me if I don't type anything for a while in the lockscreen. What I was talking about is the screen that shows up before I press a key to type the password. If I'm using a screensaver module like mpv, then instead of the black screen, mpv shows up - but when no screensaver module is used, it shows a black screen with the backlight turned on, and pressing a key brings up the dialog where we type our password. I was wondering if it was possible to turn of the backlight instead, and pressing a key brings up the dialog.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/google/xsecurelock/issues/93#issuecomment-770149345, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB5NMAWZSH6JXM3R27NF6DS4N445ANCNFSM4KDZJEMQ .

cubetastic33 commented 3 years ago

Sure, making my own saver script is totally fine with me. I tried what you said, but that turns the screen off immediately after I do anything - it turns on momentarily if I move my mouse or type something but then turns off again...

tjbrn commented 1 year ago

Are there any solutions? xset dpms force off works, but not properly with xsecurelock

#!/bin/sh
sleep 0.1
xset dpms force off
XSECURELOCK_BLANK_DPMS_STATE=off XSECURELOCK_NO_COMPOSITE=1 XSECURELOCK_COMPOSITE_OBSCURER=1 XSECURELOCK_PASSWORD_PROMPT=time xsecurelock

Tried the code above, the desktop content is exposed for half a second after pressing a key with the screen off.

sleep 1 seems to leak the screen less times than sleep 0.1, but still leak sometimes