New laptop part 5: power management
Introduction
This blog post is about a few things I put in place for screen locking and automatically suspend. It isn’t about battery optimisation.
i3lock
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
PICTURE=/tmp/i3lock.png
SCREENSHOT="scrot -z $PICTURE"
BLUR="20x16"
$SCREENSHOT
convert $PICTURE -blur $BLUR $PICTURE
i3lock -i $PICTURE
rm $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.
xss-lock
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. – https://wiki.archlinux.org/title/Power_management#xss-lock
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
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:
logind.conf
[Login]
HandlePowerKey=suspend-then-hibernate
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend-then-hibernate
HandleLidSwitchDocked=ignore
IdleAction=suspend-then-hibernate
IdleActionSec=15min
The above will start suspend-then-hibernate that will first suspend and then hibernate. To configure it, edit sleep.conf:
[Sleep]
AllowHibernation=yes
AllowSuspendThenHibernate=yes
HibernateState=disk
HibernateDelaySec=30min
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.
Conclusion
That’s it for this post, nothing crazy here. The main win for me was fixing the hibernation :).
From the « Frame.work laptop setup »: collection:
- New laptop part 7: Firefox extensions
- New laptop part 6: Managing multi screens with i3wm and autorandr
- New laptop part 5b: Prevent sleep / hibernation when home and in charge
- New laptop part 5: power management
- New laptop part 4: Dracula theme
- New laptop part 3: i3wm configuration
- New laptop part 2: Core tools
- New laptop part 1: EndeavourOS / Archlinux on the FrameWork laptop
- New laptop part 0: Discovering the FrameWork laptop