Locking Linux X Sessions without XScreensaver

 I'm currenlty using Funtoo Linux on my main laptop, and XScreenSaver was displaying a big scary warning "This version of XScreenSaver is very old! Please upgrade!". It turns out the author of XScreenSaver is, shall we say, very opinionated about downstream distros modifying this warning in any way -- though the codebase itself is allegedly free for downstream to modify, if this particular warning is touched by downstream the XScreenSaver author has insisted the program be removed entirely, said author even protesting a commonsense modification to the warning to redirect users first to the specific distribution for bug reports.

Normally I don't care so much about OSS drama, but this warning timebomb just seems antisocial. I don't care much about screensaver functionality, I just want simple session locking and the warning was bugging me. So I went searching and surprisingly there are not many other options for X session locking that aren't tightly bound to specific widget families. There's Gnome-screensaver, some built-in lock with KDE, and then there's the most neutral setup I found so far: i3lock launched from xautolock.

Depending on your desktop it takes a bit of manual setup but it's not too hard. For my XFCE4 setup, what worked for me is:

1. Create a script (remember to chmod u+x) named in ~/.config/autostart-scripts/

/usr/bin/xautolock -time 10 -locker "/usr/bin/i3lock -c 303030" &
sleep 1
pgrep xautolock && notify-send -u normal -t 4000 "xautolock active"

2. Now set that script to auto-run on login, by creating a new entry called in the XFCE4 Settings > Session and Startup, Application Autostart tab.

3. Set a keyboard shortcut eg., for Super-L, in XFCE4 Settings > Keyboard, Application Shortcuts tab, calling i3lock (use the -c option for a custom colour if you don't like the default white screen).

Log out and log in, and verify xautolock is running -- that's it!