google / xsecurelock

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

FR: Send signal to savers when authenticator opens #179

Open PaulHaeger opened 8 months ago

PaulHaeger commented 8 months ago

As a preliminary note: I already have figured out a way to do this, so minimal work is required. I'm putting this issue to find out whether there is interest in me preparing a pull request.

In order to allow for more interactivity and make it possible for a custom screensaver to emulate common behavior (e.g. the background image blurring when the prompt is active and unblurring if it isn't) there needs to be some kind of way for the saver processes to know whether the promt is active or not.

The variable XSECURELOCK_SAVER_RESET_ON_AUTH_CLOSE lets the saver be notified via a SIGUSR1 signal when the prompt disappears. So the only thing left is to send a signal to the saver when the prompt opens. Conveniently, SIGUSR2 is still unused. So I propose that a SIGUSR2 signal is sent to the saver children when the prompt is opened (when an extra option is set of course).

I currently implemented this by adding a KillAllSaverChildrenSigHandler(SIGUSR2); call in the want_auth part of int WatchChildren. To prevent the signal being sent every frame, I added a new boolean value that starts with false and is set to true when the signal has been sent once, preventing further signals from being sent. When its determined that the authenticator closed, then the boolean is set to false again.

What is left to do for a PR is:

Is there interest in me creating a PR and is there any feedback in my approach?