thingino-button
is a simple program designed to monitor input events from a specified device and execute corresponding commands based on the configuration. It is primarily aimed at embedded systems where specific actions need to be triggered by pressing, releasing, or holding buttons.
- Monitor an input device for key events.
- Execute different commands on key press, release, or timed hold.
- Configurable through a simple configuration file.
- Supports running as a daemon or in silent mode.
- Basic key support for
KEY_ENTER
and keys0-9
. More keys can be easily added by modifying the source code.
- A Linux-based system with access to the input device (e.g.,
/dev/input/event0
).
-
Clone the Repository:
git clone https://github.com/gtxaspec/thingino-button.git cd thingino-button
-
Compile the Program: To compile the program, you can use the provided Makefile. If you are cross-compiling, set the
CROSS_COMPILE
variable.make CROSS_COMPILE=mipsel-linux-
This will generate the
thingino-button
executable.
-
Create a Configuration File:
Create a file named
/etc/thingino-button.conf
with the following format:# Device to monitor DEVICE=/dev/input/event0 # Key action mappings # Format: KEY_<key_name> <action> <time> <command> KEY_ENTER PRESS 0 /bin/command1 KEY_ENTER RELEASE 0 /bin/command2 KEY_ENTER TIMED 0.1 /bin/command-timed press KEY_ENTER TIMED 3 /bin/command-timed KEY_ENTER TIMED 5 /bin/command-timed KEY_ENTER TIMED 20 /bin/command-timed
-
Run the Program:
You can run the program directly or with optional flags:
./thingino-button [-s] [-d] [input_device]
-s
: Run in silent mode, logging to syslog.-d
: Run as a daemon, logging to syslog.input_device
: Optional input device path, overrides the config file.
Example:
./thingino-button -s /dev/input/event1
The configuration file should be located at /etc/thingino-button.conf
and follows this format:
# Device to be monitored for input events
DEVICE=/dev/input/event0
# Key action mappings
# Format: KEY_<key_name> <action> <time> <command>
# - <key_name>: Name of the key (e.g., ENTER, 1, 2, etc.)
# - <action>: Type of action (PRESS, RELEASE, TIMED, TIMED_FIRE)
# - <time>: Time in seconds for TIMED, TIMED_FIRE actions (use 0 for PRESS and RELEASE)
# - <command>: Command to execute when the action occurs
# Example mappings:
KEY_ENTER PRESS 0 /bin/command1
KEY_ENTER RELEASE 0 /bin/command2
KEY_ENTER TIMED 0.1 /bin/command-timed press
KEY_ENTER TIMED 3 /bin/command-timed
KEY_ENTER TIMED 5 /bin/command-timed
KEY_ENTER TIMED 20 /bin/command-timed
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project is licensed under the MIT License.