Code Monkey home page Code Monkey logo

thingino-button's Introduction

Thingino-Button

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.

Features

  • 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 keys 0-9. More keys can be easily added by modifying the source code.

Requirements

  • A Linux-based system with access to the input device (e.g., /dev/input/event0).

Installation

  1. Clone the Repository:

    git clone https://github.com/gtxaspec/thingino-button.git
    cd thingino-button
  2. 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.

Usage

  1. 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> <command> [<time>]
    KEY_ENTER PRESS /bin/command1
    KEY_ENTER RELEASE /bin/command2 
    KEY_ENTER TIMED /bin/command-timed press 0.1
    KEY_ENTER TIMED /bin/command-timed 3
    KEY_ENTER TIMED /bin/command-timed 5
    KEY_ENTER TIMED /bin/command-timed 20
  2. 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

Configuration File Format

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> <command> [<time>]
# - <key_name>: Name of the key (e.g., ENTER, 1, 2, etc.)
# - <action>: Type of action (PRESS, RELEASE, TIMED)
# - <command>: Command to execute when the action occurs
# - [<time>]: (Optional) Time in seconds for TIMED actions

# Example mappings:
KEY_ENTER PRESS /bin/command1
KEY_ENTER RELEASE /bin/command2
KEY_ENTER TIMED /bin/command-timed press 0.1
KEY_ENTER TIMED /bin/command-timed 3
KEY_ENTER TIMED /bin/command-timed 5
KEY_ENTER TIMED /bin/command-timed 20

Contributing

Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.

License

This project is licensed under the MIT License.

thingino-button's People

Contributors

gtxaspec avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.