Triggerhappy is a lightweight hotkey daemon that can launch arbitrary commands
on input events. It supports the hotplugging of devices and the processing of
key combinations.

Signed-off-by: Stefan Tomanek <stefan.tomanek+open...@wertarbyte.de>
---
 utils/triggerhappy/Makefile                        |   49 ++++++++++++++++++++
 utils/triggerhappy/files/triggerhappy-example.conf |   15 ++++++
 utils/triggerhappy/files/triggerhappy.hotplug      |   15 ++++++
 utils/triggerhappy/files/triggerhappy.init         |   10 ++++
 4 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100644 utils/triggerhappy/Makefile
 create mode 100644 utils/triggerhappy/files/triggerhappy-example.conf
 create mode 100644 utils/triggerhappy/files/triggerhappy.hotplug
 create mode 100644 utils/triggerhappy/files/triggerhappy.init

diff --git a/utils/triggerhappy/Makefile b/utils/triggerhappy/Makefile
new file mode 100644
index 0000000..41092a6
--- /dev/null
+++ b/utils/triggerhappy/Makefile
@@ -0,0 +1,49 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=triggerhappy
+PKG_VERSION:=0.1.3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://github.com/wertarbyte/triggerhappy/tarball/release/
+PKG_MD5SUM:=7da137a7d2ba1ce396231e821e68de4e
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/wertarbyte-triggerhappy-f7c4216/
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/triggerhappy
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=execute commands when a key or switch is pressed, released or hold 
down
+  URL:=http://github.com/wertarbyte/triggerhappy
+endef
+
+define Package/triggerhappy/description
+       triggerhappy - execute commands when a key or switched is pressed, or 
hold down
+endef
+
+MAKE_FLAGS += \
+       $(TARGET_CONFIGURE_OPTS) \
+       $(1)
+
+define Package/triggerhappy/install
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_DIR) $(1)/etc
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/etc/triggerhappy
+       $(INSTALL_DIR) $(1)/etc/triggerhappy/triggers.d/
+       $(INSTALL_DIR) $(1)/etc/hotplug.d/input/
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/thd $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/th-cmd $(1)/usr/sbin
+       $(INSTALL_BIN) ./files/triggerhappy.init $(1)/etc/init.d/triggerhappy
+       $(INSTALL_BIN) ./files/triggerhappy.hotplug 
$(1)/etc/hotplug.d/input/10-triggerhappy
+       $(INSTALL_BIN) ./files/triggerhappy-example.conf 
$(1)/etc/triggerhappy/triggers.d/example.conf
+endef
+
+$(eval $(call BuildPackage,triggerhappy))
diff --git a/utils/triggerhappy/files/triggerhappy-example.conf 
b/utils/triggerhappy/files/triggerhappy-example.conf
new file mode 100644
index 0000000..bcff574
--- /dev/null
+++ b/utils/triggerhappy/files/triggerhappy-example.conf
@@ -0,0 +1,15 @@
+# This is an example configuration for the triggerhappy daemon (thd)
+# please note that every file to be processed must end in ".conf"
+#
+# To view a list of supported event codes, use "thd --listevents" or
+# "thd --dump /dev/input/event*"
+#
+# Format:
+# <eventcode> <value> <command>
+#
+# values for key events are 1 (pressed), 0 (released) or 2 (held)
+#
+#
+## control an mpd instance
+# KEY_NEXTSONG         1       /usr/bin/mpc next
+# KEY_PREVSONG         1       /usr/bin/mpc prev
diff --git a/utils/triggerhappy/files/triggerhappy.hotplug 
b/utils/triggerhappy/files/triggerhappy.hotplug
new file mode 100644
index 0000000..78ad349
--- /dev/null
+++ b/utils/triggerhappy/files/triggerhappy.hotplug
@@ -0,0 +1,15 @@
+#!/bin/sh
+THD_SOCKET=/tmp/triggerhappy.socket
+[ -S "$THD_SOCKET" ] || exit
+
+case "$ACTION" in
+       add)
+               DEVICE="/dev/$DEVNAME"
+               [ -c "$DEVICE" ] || exit
+               # offer device to triggerhappy daemon
+               /usr/sbin/th-cmd --socket "$THD_SOCKET" --add "$DEVICE"
+       ;;
+        remove)
+               # nothing to do
+       ;;
+esac
diff --git a/utils/triggerhappy/files/triggerhappy.init 
b/utils/triggerhappy/files/triggerhappy.init
new file mode 100644
index 0000000..e846d29
--- /dev/null
+++ b/utils/triggerhappy/files/triggerhappy.init
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+START=93
+
+start() {
+       /usr/sbin/thd --socket /tmp/triggerhappy.socket --triggers 
/etc/triggerhappy/triggers.d/ --daemon /dev/input/event*
+}
+
+stop() {
+       /usr/sbin/th-cmd --socket /tmp/triggerhappy.socket --quit
+}
-- 
1.7.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to