ninwa/README.md

91 lines
3.1 KiB
Markdown
Raw Normal View History

2022-02-15 04:33:19 +01:00
# ninwa
2022-02-16 01:36:09 +01:00
node input watcher
## requirements
- evtest
- node.js
- [nvm](https://github.com/nvm-sh/nvm)
## setup (as root)
2022-02-16 01:36:09 +01:00
- install nvm
2022-02-16 01:36:09 +01:00
- to load nvm restart your terminal or `source ~/.nvm/nvm.sh`
2022-02-16 01:36:09 +01:00
- clone the project (to '/opt/ninwa')
`git clone https://git.velvettear.de/velvettear/ninwa.git /opt/ninwa`
2022-02-16 01:36:09 +01:00
- install and switch to a supported node.js version (automatically done via .nvmrc file)
`nvm install`
2022-02-16 01:36:09 +01:00
- install the required modules
`npm install`
- switch back to your system's default node.js version
`nvm deactivate`
2022-02-16 01:36:09 +01:00
- execute ninwa
`nvm run ninwa.js`
2022-02-16 01:36:09 +01:00
## 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`
2022-02-16 01:36:09 +01:00
- symlink the provided systemd-service file and modify it according to your needs
`ln -s /opt/ninwa/ninwa.service /etc/systemd/system/ninwa.service`
2022-02-16 01:36:09 +01:00
- 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`.
2022-04-06 09:59:19 +02:00
### server: [*object*]
- address: [*string*] server address to listen on (`0.0.0.0` to listen on all interfaces)
- port: [*number*] port to listen on
2022-02-16 01:36:09 +01:00
### log: [*object*]
- level: [*string*] verbosity of the log; either `debug`, `info`, `warning` or `error`
- timestamp: [*string*] format string for the timestamp; review [moment.js](https://momentjs.com/docs/#/displaying/format/) for further information
2022-03-11 15:59:03 +01:00
### combos: [*object*]
- delay: [*number*] time in milliseconds until a combo will be reset
2022-03-03 03:35:34 +01:00
2022-02-16 01:36:09 +01:00
### 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
2022-03-03 03:35:34 +01:00
- restart: [*boolean*] restart watcher on close
2022-03-11 15:59:03 +01:00
- sudo: [*boolean*] use sudo to start the evtest process
2022-02-16 01:36:09 +01:00
- keys: [*object-array*]
- key: [*string*] name of the key
2022-03-11 15:59:03 +01:00
- combo: [*string-array*] name of one or more keys (in order)
- event: [*string*] [event type](https://www.kernel.org/doc/html/latest/input/event-codes.html) to filter evtest's output for
2022-02-16 01:36:09 +01:00
- type: [*string*] type of the key event; either `keyup`, `keydown` or `keyhold`
2022-03-11 15:59:03 +01:00
- delay: [*number*] time in milliseconds until the key will be registered again (mostly useful for keyhold-events; **unavailable for combos**)
- command: [*string*] name of the command to execute on key press / combo end
### commands: [*object*]
- *name*: [*object*]
- cmd: [*string*] command / path to script to execute
2022-03-11 16:00:46 +01:00
- args: [*string-array*] arguments to pass to the executed command
2022-03-24 10:36:23 +01:00
- sudo: [*boolean*] use sudo to execute the command
**note:**
if you intend to use ninwa as a systemd-service with `sudo` make sure the configured user is allowed to execute the command without entering a password. **otherwise your service will just stop at the password prompt!**
- `sudo visudo`
- `username ALL=(ALL) NOPASSWD: command`