Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node JS - listen for system events

As per below API doc, Node JS listen for process exit event. https://nodejs.org/api/process.html#process_event_exit

How can Node JS listen for system event? Such as, USB inserted, CAMERA device inserted into system or any custom events emitted by Linux.

like image 430
Nitul Avatar asked Dec 06 '25 09:12

Nitul


1 Answers

Since in Linux "Everything is a file" you can monitor the /dev directory for changes. I use this nodejs inotify binding:

node-inotify - http://c4milo.github.io/node-inotify/

like image 149
Rui Sebastião Avatar answered Dec 07 '25 23:12

Rui Sebastião



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!