Change default behavior of pressing power button

Simon Fels simon.fels at canonical.com
Wed Nov 30 13:12:04 UTC 2016


On 30.11.2016 11:21, Robert Liu wrote:
> Hi All,
> 
> The default behavior of pressing power button is power off and I want to
> change it to suspend.
> 
> The configuration file /etc/systemd/logind.conf is in the core snap and
> is read-only.
> I found that there are at least the following methods:
> 1. write my own logind.conf, bind mount it and restart
> systemd-logind.service
> 2. write my own inhibitor and use systemd-inhibit
> However these two methods must be run at every boot.
> 
> I am wondering if there is any other solutions?
> Or we could include /etc/systemd/logind.conf in writable-paths?

The plan is to have power management policy decisions covered by snapd
so the actual system doesn't need to care about. We're still in the
beginning of designing this but my rough feeling is that this would go
into the policy decision as another variable which can be configured
somewhere per device.

What you still can do in the mean time is creating a custom systemd unit
and placing it in /etc/systemd/system which does the bind mount and
restarts logind. See
https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager/tree/tests/image/create-image.sh
for an example of how you can integrate this in an image build with
ubuntu-image. But please keep in mind that this is a very hacky approach
and would mean it can't be updated on a device once the image is released.

regards,
Simon





More information about the Snapcraft mailing list