systemd-conf: machine-configurable power key behavior

Use placeholders and machine-configurable variables to determine systemd
behavior when receiving power key events.
By default, these are:
- short press: suspend
- long press: graceful poweroff

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
This commit is contained in:
Hector Palacios 2026-02-24 17:05:00 +01:00
parent ebe606d9ac
commit 6b9d2e4114
3 changed files with 10 additions and 2 deletions

View File

@ -130,3 +130,7 @@ IMAGE_FSTYPES ?= "${@ \
'' , d), \
d) \
}"
# Systemd logind power key event
LOGIND_HANDLE_POWER_KEY ??= "suspend"
LOGIND_HANDLE_POWER_KEY_LONGPRESS ??= "poweroff"

View File

@ -1,3 +1,3 @@
[Login]
HandlePowerKey=suspend
HandlePowerKeyLongPress=poweroff
HandlePowerKey=##HANDLEPOWERKEY##
HandlePowerKeyLongPress=##HANDLEPOWERKEYLONGPRESS##

View File

@ -20,8 +20,12 @@ do_install:append() {
do_install:append:stm32mpcommon() {
install -D -m0644 ${WORKDIR}/logind.conf-digi ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf
sed -i -e 's,##HANDLEPOWERKEY##,${LOGIND_HANDLE_POWER_KEY},g' \
-e 's,##HANDLEPOWERKEYLONGPRESS##,${LOGIND_HANDLE_POWER_KEY_LONGPRESS},g' ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf
}
do_install:append:ccimx9() {
install -D -m0644 ${WORKDIR}/logind.conf-digi ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf
sed -i -e 's,##HANDLEPOWERKEY##,${LOGIND_HANDLE_POWER_KEY},g' \
-e 's,##HANDLEPOWERKEYLONGPRESS##,${LOGIND_HANDLE_POWER_KEY_LONGPRESS},g' ${D}${systemd_unitdir}/logind.conf.d/01-${PN}.conf
}