pm-suspend on Ubuntu

After upgrade to Ubuntu 16.04 I recognized that pm-utils are not used anymore to suspend/resume my notebook. The change was already done with Ubuntu 15.04, but I haven’t recognized it before, because everything was working like expected. I recognized it these days after I changed my windowmanager to i3wm.

Since Ubuntu 15.04 they don’t use the pm-utils like pm-suspend any more. They use now systemctl commands to suspend if the lid is closed. Therefore my screenlock was not working any more and I had to adapt some things to get the i3 screenlocker i3lock to work.

What happened? — first try with pm-utils

I switched my windowmanager as described above to the i3wm. Before I used openbox and handled for a long time my notebook suspend at lid close via pm-utils. Therefore I used the handler.sh script like described in my previous post configure acpid for openbox.

i3 uses i3lock to lock the screen. So I changed my settings in handler.sh to use i3lock instead of gnome-screensaver-command --lock. I restarted the acpid and closed the lid to test if the new line is working. I recognized that after the lid was closed, my notebook was suspended, but the screen lock was not working.

After some try and error, I also figured out, that I changed my username some weeks before. That was one of the reasons why the i3lock command was not executed. But why the suspend worked?!

Some questions to google and some stackoverflow searches later I knewed that Ubuntu now uses systemctl commands like /lib/systemd/system/systemd-suspend.service to suspend the system.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Suspend
Documentation=man:systemd-suspend.service(8)
DefaultDependencies=no
Requires=sleep.target
After=sleep.target

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-sleep suspend

$ man systemd-sleep

......

systemd-suspend.service is a system service that
is pulled in by suspend.target and is responsible for the actual system suspend.
Similarly, systemd-hibernate.service is pulled in by hibernate.target to execute
the actual hibernation.....

pm-utils still works somehow

If I put in the correct username and have executable rights set to handler.sh the pm-utils part ist somehow still working, because the pm-utils still fires the closed event. But I don’t need to use the pm-suspend here any more.

Therefore I just use the handler.sh for my screen lock. My new handler.sh now looks like:

$ cat /etc/acpi/handler.sh
#!/bin/sh
case $(cat /proc/acpi/button/lid/LID/state | awk '{print $2}') in
    closed) DISPLAY=:0.0 su - max -c "/usr/bin/i3lock -c 000000 -n";;
esac
comments powered by Disqus