Fixing a frozen screen caused by systemd 256

Posted on Sat 03 August 2024 in Technical

Systemd version 256 has been rolled out in several distributions recently, including Arch and Debian and variants. It adds a feature where user sessions are frozen when the system enters sleep, but in my case, running Manjaro Linux with KDE on a Gen 1 Lenovo T14, this meant that when the system woke, the screen remained frozen and required a reboot by switching to the command line with Ctrl-Alt-F3.
At first I perhaps unfairly assumed that this was KDE as it affected the desktop but left the mouse working and indeed the system accessible with through the console, but after a bit of digging around in the system journal with journalctl -b-1 -p4 --no-pager (a really useful command that I didn't know before), I found the error Cannot start frozen unit Session 10 of User xxxxx from systemd.
Searching on that brought up the problem and conclusively pointed at the 256 update, and a solution, or at least a fix until the issue is fixed.
The fix is to add an override to the systemd-suspend service. This doesn't actually have a service file in /etc/systemd/system in Manjaro at least, so you need to create the directory /etc/systemd/system/systemd-suspend.service.d and create an override file called disable_freeze_user_session.conf with these contents:

[Service]
Environment="SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=false"

Save this, and restart systemd with systemctl daemon-reload.
This disables user freeze on sleep and for me at least, reverted to the previous behaviour. I found that a lot of the examples mentioned Nvidia video hardware, which I don't have, so it's probably a wider issue than I've found.
I've added a comment to the Github issue.