m0g / node-udev

Bindings to libudev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-udev - list devices in system and detect changes on them

This library attempts to follow the libudev where it makes sense. I only needed some usb input device detection so I was happy with quite few features.

Requires node-v0.8.0, nan and libudev.

Installation

npm install udev

Installation on debian/ubuntu

sudo apt-get install libudev-dev
npm install udev

How to Use

The example below lists devices and monitors udev events and closes its monitor when receiving an add -event. The code is separately listed in samples/howto.js.

var udev = require("udev");

console.log(udev.list()); // this is a long list :)

var monitor = udev.monitor();
monitor.on('add', function (device) {
    console.log('added ' + device);
    monitor.close() // this closes the monitor.
});
monitor.on('remove', function (device) {
    console.log('removed ' + device);
});
monitor.on('change', function (device) {
    console.log('changed ' + device);
});

About

Bindings to libudev


Languages

Language:C++ 84.5%Language:JavaScript 12.6%Language:Python 2.9%