What I’m about to show you works for me quite well (YMMV - and in the end, may not be what you are looking for).
I installed xsceensaver also since I actually want a screen saver to kick in.
In my i3 config I have these 2 lines.
exec --no-startup-id xscreensaver -no-splash &
exec --no-startup-id xautolock -time 30 -locker “i3lock -c 000000”
You will need to run xscreensaver to set the parms you want. For example, you may only want one screen saver opposed to the default of random. You will also want to set the time outs too.
In my .xscreensaver file, I have these set for my default timings:
So basically, the screensaver kicks in in 15 mins. The lock timeout is set to 0 (that means it requires a password once the screensaver kicks in. And of course, once you are prompted for
the password via xscreensaver, you have 30 seconds before it goes back to the screensaver.
and lastly, I don’t want xscreensaver to display the splash screen (because it will give someone the ability to change the screensaver settings at that point).
The second line I have in the i3 config simply sets the auto-lock color to a black screen. I have a feeling that that line is just left over and I never removed it so it may not be needed.
In my case, once I close the lid, the lappy hibers and when I open it - I am prompted for a password.
Give it a shot, tweak as you need to and in the end, it’s all about what you want and how you wan to do it. This is just what I have done and works well for me.
As an alternative, lots of folks have xfce4-power-manager installed and control all of the settings via xfce4-settings-manager too