From: David Kennedy <qpg7x5@masqt.com>
---
hooks/README.md | 35 ++++++++++++++++++++++hooks/inputhandler/README.md | 17 +++++++++++hooks/inputhandler/android_buttons | 48 ++++++++++++++++++++++++++++++
3 files changed, 100 insertions(+)
create mode 100644 hooks/README.md
create mode 100644 hooks/inputhandler/README.md
create mode 100755 hooks/inputhandler/android_buttons
diff --git a/hooks/README.md b/hooks/README.md
new file mode 100644
index 0000000..3b933b0
--- /dev/null+++ b/hooks/README.md
@@ -0,0 +1,35 @@
+# User hooks++This directory contains example hooks contributed by the community.++# Usage++To use one of these hooks, copy it to `$XDG_CONFIG_HOME/sxmo/hooks/[name]`,+where `[name]` is the name of the directory containing the file, and make it+executable.++For example:++```+$ cp inputhandler/android_buttons $XDG_CONFIG_HOME/sxmo/hooks/inputhandler+$ chmod u+x $XDG_CONFIG_HOME/sxmo/hooks/inputhandler+```++# Contributing++Add your own hooks under a directory corresponding to the hook name and rename+the file itself something descriptive. This way, we can have multiple examples+of each type of hook organized like so:++```+hooks/+ inputhandler/+ README.md+ android_buttons+ inverted_volume+ ...+```++Please also add a brief description of your hook to the README in its parent+directory.+
diff --git a/hooks/inputhandler/README.md b/hooks/inputhandler/README.md
new file mode 100644
index 0000000..ebda088
--- /dev/null+++ b/hooks/inputhandler/README.md
@@ -0,0 +1,17 @@
+# inputhandler hooks++This directory contains example inputhandler hooks.++# Caveats++As of version 1.5.1, this hook is only executed when the screen is unlocked.+It's not possible to modify the behavior of the power button when locked.++# Contents++## android_buttons+- Author: David Kennedy+- License: WTFPL+- Description: Modifies the hardware button behavior to mimic a typical Android+ device.+
diff --git a/hooks/inputhandler/android_buttons b/hooks/inputhandler/android_buttons
new file mode 100755
index 0000000..99310a8
--- /dev/null+++ b/hooks/inputhandler/android_buttons
@@ -0,0 +1,48 @@
+#!/bin/sh++# This hook modifies the hardware button behavior to mimic a typical Android+# device, i.e.:+#+# - The power button locks the screen and turns it off+# - The volume up button turns the volume up+# - The volume down button turns the volume down+#+# It also adds a couple features that don't normally exist on Android:+#+# - Holding the power button enters CRUST suspend+# - Holding the volume down button mutes the volume+#+# You still have to hold down the power button to unlock the screen.++WMCLASS="$1"+WMNAME="$2"+ACTION="$3"++# You must exit 0 if you handled the input to not trigger default behaviors++case "$ACTION" in+ powerbutton_three)+ sxmo_screenlock.sh crust+ exit 0+ ;;+ powerbutton_*)+ sxmo_screenlock.sh off+ exit 0+ ;;+ volup_*)+ sxmo_vol.sh unmute+ sxmo_vol.sh up+ exit 0+ ;;+ voldown_three)+ sxmo_vol.sh mute+ exit 0+ ;;+ voldown_*)+ sxmo_vol.sh down+ exit 0+ ;;+esac++exit 1+
--
2.32.0