diff options
Diffstat (limited to 'meta-raspberrypi/recipes-bsp/gpio-shutdown')
3 files changed, 46 insertions, 0 deletions
diff --git a/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/bind_gpio_shutdown.tab b/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/bind_gpio_shutdown.tab new file mode 100644 index 0000000000..00cc4857d8 --- /dev/null +++ b/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/bind_gpio_shutdown.tab @@ -0,0 +1,2 @@ +# Action on special keypress (Key Power) +kb::kbrequest:/sbin/shutdown -t1 -a -h -P now diff --git a/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/gpio-shutdown-keymap.sh b/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/gpio-shutdown-keymap.sh new file mode 100644 index 0000000000..bae50daf14 --- /dev/null +++ b/meta-raspberrypi/recipes-bsp/gpio-shutdown/files/gpio-shutdown-keymap.sh @@ -0,0 +1,13 @@ +#!/bin/sh +## +# Bind the gpio-shutdown keycode as Keyboard signal and load it to the +# keymap during startup. +## +case "$1" in + start) + # Inject the gpio keycode to keymap + echo "keycode 116 = KeyboardSignal" | loadkeys + ;; + *) + ;; +esac diff --git a/meta-raspberrypi/recipes-bsp/gpio-shutdown/gpio-shutdown.bb b/meta-raspberrypi/recipes-bsp/gpio-shutdown/gpio-shutdown.bb new file mode 100644 index 0000000000..d6908400bd --- /dev/null +++ b/meta-raspberrypi/recipes-bsp/gpio-shutdown/gpio-shutdown.bb @@ -0,0 +1,31 @@ +SUMMARY = "GPIO shutdown bindings for SysV init" +LICENSE = "GPL-2.0-only" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" + +SRC_URI = "file://bind_gpio_shutdown.tab \ + file://gpio-shutdown-keymap.sh \ +" + +inherit update-rc.d + +INITSCRIPT_NAME = "gpio-shutdown-keymap.sh" +# Run only once during startup +INITSCRIPT_PARAMS = "start 99 S ." + +do_install() { + # The files are only needed if using SysV init. + if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then + install -d ${D}${sysconfdir} \ + ${D}${sysconfdir}/inittab.d \ + ${D}${sysconfdir}/init.d + + install -m 0755 ${WORKDIR}/gpio-shutdown-keymap.sh ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/bind_gpio_shutdown.tab ${D}${sysconfdir}/inittab.d/ + elif ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then + # Systemd init does not require any configuration. + # Note: cannot have an empty branch, hence the redundant dir install. + install -d ${D}${sysconfdir} + else + bbwarn "Not using sysvinit or systemd. The gpio-shutdown may require additional configuration." + fi +} |