ninwa/README.md

2.3 KiB

ninwa

node input watcher

requirements

  • evtest
  • node.js
  • nvm

setup (as root)

  • install nvm

  • to load nvm restart your terminal or source ~/.nvm/nvm.sh

  • clone the project (to '/opt/ninwa')
    git clone https://git.velvettear.de/velvettear/ninwa.git /opt/ninwa

  • install and switch to a supported node.js version (automatically done via .nvmrc file) nvm install

  • install the required modules
    npm install

  • switch back to your system's default node.js version nvm deactivate

  • execute ninwa
    nvm run ninwa.js

systemd

for security reasons it is highly recommended to not run ninwa with root permissions!

  • create a new system user
    useradd -U -r -s /usr/bin/nologin node

  • make your install of nvm available to the new user
    cp -R ~/.nvm /opt/nvm
    chown -R node /opt/nvm

  • symlink the provided systemd-service file and modify it according to your needs
    ln -s /opt/ninwa/ninwa.service /etc/systemd/system/ninwa.service

  • reload systemd-services
    systemctl daemon-reload

  • enable and start the ninwa as a systemd-service
    systemctl enable --now ninwa

configuration

configuration is done entirely within the file config.json.

log: [object]

  • level: [string] verbosity of the log; either debug, info, warning or error
  • timestamp: [string] format string for the timestamp; review moment.js for further information

socket: [object]

  • location: [string] path to the socket file; defaults to /tmp/ninwa.sock

watchers: [object-array]

  • device: [string] name of or path to an input device; ninwa automatically tries to locate the device in /dev/input and /dev/input/by-id/ if only a name is given
  • restart: [boolean] restart watcher on close
  • grep: [string] pre-filter evtest's output with grep
  • keys: [object-array]
    • key: [string] name of the key
    • type: [string] type of the key event; either keyup, keydown or keyhold
    • delay: [number] time in milliseconds until the key will be registered again (mostly useful for keyhold-events)
    • command: [string] command to execute on key press
    • args: [string-array] arguments to pass to the executed command; variables {{ key }} and {{ type }} used in args will be replaced