before-sleep runs when systemd-logind emits PrepareForSleep(true), i.e. right before the system actually goes to sleep. If suspend is delayed by inhibitors, that hook will be delayed too.
Some problematic situation:
- I close the lid.
- For some reason, my laptop takes forever to go to sleep (e.g. ~5 mins).
- After 2 mins, I open again the lid. The screen isn't locked...
It is far from good from a security standpoint.