New laptop part 5: power management

Saturday, February 18, 2023



This blog post is about a few things I put in place for screen locking and automatically suspend. It isn’t about battery optimisation.


To lock the screen, I’m using i3lock. As for the lock image, instead of using a “static” image, I’m using a blur image of the current screen. I find it more dynamic.

To create a blur image of the desktop and use with i3lock, I use this script from EndeavourOS i3wm configuration:

The script is ~/.config/i3/scripts/blur-lock:

#!/usr/bin/env bash



convert $PICTURE -blur $BLUR $PICTURE
i3lock -i $PICTURE

I just changed the BLUR variable (from 5x4 to 20x16) to blur even more the image. With that, even if I leave the screen on a chat app, it will blurry enough to not be readable at all.

Original script can be found on github.


As the archlinux wiki says:

xss-lock subscribes to the systemd-events suspend, hibernate, lock-session, and unlock-session with appropriate actions (run locker and wait for user to unlock or kill locker). xss-lock also reacts to DPMS events and runs or kills the locker in response. –

This means that when a lock-session events will be launched, xss-lock will trigger a command. In my case, the script above that start i3lock with the blurred image.

To install it:

sudo pacman -S xss-lock

To test it:

xss-lock -- /home/bacardi55/.config/i3/scripts/blur-lock

Then, to start it at the start of the session, I put in my i3 config (~/.config/i3/config):

exec --no-startup-id xss-lock -- /home/bacardi55/.config/i3/scripts/blur-lock

Rofi script

The power menu allow easy select to hibernate, suspend, lock, logout, reboot or shutdown:

Figure 1: Screenshots of the power menu

Figure 1: Screenshots of the power menu

This script comes from EndeavourOS i3wm configuration.

Lock screen automatically

To lock the screen automatically after 10min, I use xautolock and start it within my i3 config:

exec --no-startup-id xautolock -time 10 -locker "~/.config/i3/scripts/blur-lock"

After installing xautolock, of course:

sudo pacman -S xautolock

Suspend automatically

To suspend the screen automatically after 15 minutes, edit the /etc/systemd/logind.conf:



The above will start suspend-then-hibernate that will first suspend and then hibernate. To configure it, edit sleep.conf:


Normally, it should suspend after 15min and move to hibernation 30min later.

Fixing hibernation

I finally managed to fix hibernation on my installation. This was due to dracut configuration missing. EndeavourOS switched to dracut from mkinitcpio. All I needed to do was to add:

add_dracutmodules+=" resume "

In the /etc/dracut.conf.d/calamares-luks.conf file. And then rebuild initramfs:

sudo dracut-rebuild

Thanks a lot Lorenzo’s post for this! Read his post for more information too.


That’s it for this post, nothing crazy here. The main win for me was fixing the hibernation :).


If you find any issue or have any question about this article, feel free to reach out to me via email, mastodon, matrix or even IRC, see the About Me page for details.

See Also

13 years of blogging

New laptop part 4: Dracula theme