Hi,

Here is a new package called acpid and a related kernel module
kmod-button. Its main pupose is to listen for
acpi events and run a user defined script. For now only powerdown is
possible. I only tested this under the
X86 architecture.

Maybe somebody find that useful too.

regards.
thomas

-- 
Thomas Heil
-
! note my new number !
Skype: phiber.sun
Email: [email protected]
Tel:   0176 / 44555622
--


Index: package/kernel/modules/other.mk
===================================================================
--- package/kernel/modules/other.mk	(revision 30893)
+++ package/kernel/modules/other.mk	(working copy)
@@ -872,3 +872,21 @@
 
 $(eval $(call KernelPackage,nandsim))
 
+define KernelPackage/button
+  SUBMENU:=$(OTHER_MENU)
+  TITLE:=ACPI Button Support
+	DEPENDS:=kmod-input-evdev
+  KCONFIG:= CONFIG_ACPI=y \
+  	CONFIG_PM=y \
+  	CONFIG_INPUT=y \
+  	CONFIG_ACPI_BUTTON
+  DEPENDS:=@TARGET_x86
+  FILES:=$(LINUX_DIR)/drivers/acpi/button.$(LINUX_KMOD_SUFFIX)
+  AUTOLOAD:=$(call AutoLoad,06,button)
+endef
+ 
+define KernelPackage/button/description
+  Kernel module for ACPI Butoon support
+endef
+
+$(eval $(call KernelPackage,button))
Index: packages/utils/acpid/files/acpid.hotplug
===================================================================
--- packages/utils/acpid/files/acpid.hotplug	(revision 0)
+++ packages/utils/acpid/files/acpid.hotplug	(revision 0)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+. /etc/functions.sh
+
+if [ "$ACTION" = add ] && [ "$DEVICENAME" = event0 ]; then
+        ( /etc/init.d/acpid/stop; sleep 3; /usr/sbin/acpid )&
+fi
Index: packages/utils/acpid/files/acpid.init
===================================================================
--- packages/utils/acpid/files/acpid.init	(revision 0)
+++ packages/utils/acpid/files/acpid.init	(revision 0)
@@ -0,0 +1,25 @@
+#!/bin/ash /etc/rc.common
+# Copyright (C) 2009-2010 OpenWrt.org
+
+START=99
+STOP=80
+
+ACPID_BIN="/usr/sbin/acpid"
+ACPID_PID="/var/run/acpid.pid"
+
+start() {
+    [ -x "$ACPID_BIN" ] || return 1
+    start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
+}
+
+boot() {
+	# Do nothing on boot
+    	[ -x "$ACPID_BIN" ] || return 1
+	start-stop-daemon -S -x $ACPID_BIN -p $ACPID_PID
+	exit 0
+}
+
+stop() {
+	service_kill ${ACPID_BIN##*/} $ACPID_PID
+	rm -f $ACPID_PID
+}

Property changes on: packages/utils/acpid/files/acpid.init
___________________________________________________________________
Added: svn:executable
   + *

Index: packages/utils/acpid/files/default
===================================================================
--- packages/utils/acpid/files/default	(revision 0)
+++ packages/utils/acpid/files/default	(revision 0)
@@ -0,0 +1,5 @@
+# This is a sample ACPID configuration
+
+event=button/power.*
+action=/sbin/poweroff 
+
Index: packages/utils/acpid/Makefile
===================================================================
--- packages/utils/acpid/Makefile	(revision 0)
+++ packages/utils/acpid/Makefile	(revision 0)
@@ -0,0 +1,65 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=acpid
+PKG_VERSION:=2.0.10
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://tedfelix.com/linux/
+PKG_MD5SUM:=d5dd88bcfaa4a0bf51905e95115da6df
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/acpid
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=The ACPI Daemon (acpid) With Netlink Support
+  URL:=http://tedfelix.com/linux/acpid-netlink.html
+  DEPENDS:=+kmod-input-evdev +kmod-button 
+endef
+
+define Package/acpid/description
+  The ACPI Daemon (acpid) With Netlink Support
+endef
+
+define Build/Compile
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		LD="$(TARGET_CC)" \
+		LDFLAGS="$(TARGET_LDFLAGS)" \
+		all 
+endef
+
+define Package/acpid/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpid $(1)/usr/sbin/
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/acpi_listen $(1)/usr/sbin/
+	$(INSTALL_DIR) $(1)/etc/acpi/events
+	$(INSTALL_CONF) ./files/default $(1)/etc/acpi/events/default
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_CONF) ./files/acpid.init $(1)/etc/init.d/acpid
+	chmod 0750 $(1)/etc/init.d/acpid
+	$(INSTALL_DIR) $(1)/etc/hotplug.d/input/
+	$(INSTALL_CONF) ./files/acpid.hotplug $(1)/etc/hotplug.d/input/
+endef
+
+define Package/acpid/postinst
+#!/bin/sh
+[ -n "$${IPKG_INSTROOT}" ] || {
+	echo "waiting for input devices to come up"
+	/etc/init.d/acpid enable
+	sleep 5
+	/usr/sbin/acpid
+	echo "please try the power button"
+	exit 0
+}
+endef
+
+$(eval $(call BuildPackage,acpid))
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to