Automated Screen Locking with Arcolinux + Qtile

Oct 10, 2022

Being a bit of user interface snob, I prefer tiling window managers (TWMs) over traditional floating window managers. Since the modus operandi of TWMs is complete user control and following the Unix Philosophy of

"Do one thing and do it well"

and they tend to be rather minimal. This minimalism allows users to customize the tiling window manager to their heart's content. The Arcolinux group graciously provides builds of the distribution that include specific desktop environments/window managers. I am going to concentrate this article on one:

ArcolinuxB + Qtile

The ISO includes many custom utitlities to help configure your system. However, certain decicions were made by the Arcolinux team for the sake of being able to sanely crank out of these ArcolinuxB ISOs (26 at last count) in a timely manner. One of the decisions was to use xfce4-powermanager to handle screen blanking and betterlockscreen to handle screen locking. They work OK, but don't actually coordinate with each other.

To correct this oversight, I installed xidlehook, a Rust-based fork of xautolock that adds a few new features. To this, I add my own special sauce in the form of a custom configuration, some modified settings in archlinux-logout and the installation of a systemd service (with a second one for laptops).

Here are the steps for a desktop PC:

  1. paru -S xidlehook
  2. git clone
  3. cp ~/twm-screenlock/xidlehook/xidlehook.service ~/.config/systemd/user/
  4. 'cp ~/twm-screenlock/archlinux-logout/archlinux-logout.conf ~/.config/archlinux-logout/`
  5. systemctl --user enable --now xidlehook.service
  6. Edit ~/.config/qtile/scripts/
  7. Add systemctl --user restart xidlehook.service (this will fix the service crashing if you restart Qtile)
  8. Save the file.
  9. Open the Control Panel (Ctrl + M)
  10. Click on Power Manager.
  11. Make sure Sleep and Hibernation are set tot Suspend.
  12. On the Display tab, disable screen blanking.
  13. Logout and login.

That will allow xidlehook to trigger betterlockscreen at a pre-determined interval of idle time, but not if audio or fullscreen video is playing. The screen will then blank after 30 seconds. Edit the xidlehook.service to adjust the timeout value.

For a laptop PC, do all of the above plus the following:

  1. sudo cp ~/twm-screenlock/betterlockscreen/[email protected] /etc/systemd/system/
  2. sudo systemctl enable [email protected] (Replace USER with your user ID).
  3. In the Power Manager Control Panel, make sure lid locking is set to suspend.

Now when you close your lid to suspend the machine, betterlockscreen will be triggered before the suspend command and when you open your lid, it will be screen locked.

Remember to clean up after yourself.