How to override and or modify a file in host OS ( /etc/ )

Hi, I’m in need of modifying the file in /etc/systemd/logind.conf

Specifically what I’m trying to achieve is being able to override the HandlePowerKey property in that file to add custom behaviour to the button event instead of having the device shut off.

I was that hoping modifying the /mnt/state/root-overlay/etc/systemd would mirror changes but it doesn’t appear to do so.

What is the balena way to be able to accomplish what I’m trying to do?

Hey Simon, what you are basically needing is a user space daemon that listens for kernel ACPI events are performs a specific action. On most systems this is handled by systemd-login as you describe, but that is not ideal in this case as you would need to run a container with systemd. Not impossible, but an unrequired complication. A better approach would be to run something like busybox acpi daemon (Busybox acpid - Alpine Linux) and configure it to execute a custom script when it detects the press event.

One thing that confuses me is that you mention that currently the system is powering off when the button is pressed. That means that either there already is something handling the event, in which case you would need to find it and modify it, or it is hardware driven, in which case there is not much you can do about it unless you can disable the hardware action.

It is the actual power button which I am pressing, for further context I am using the iot-gate-imx8 device.

If I were to be able to modify the configuration file for the login-daemon I should be able to prevent the device shutting down when pressing the button for less than 5 seconds.

I am already able to listen to the button press, although it will inevitably trigger a shutdown.