Skip to content

Instantly share code, notes, and snippets.

@schappim
Created June 14, 2012 02:50
Show Gist options
  • Save schappim/2927794 to your computer and use it in GitHub Desktop.
Save schappim/2927794 to your computer and use it in GitHub Desktop.
Node.js code to check for presence of video for linux device.
var Inotify = require('inotify-plusplus'), // should be 'inotify++', but npm has issues with the ++
inotify,
directive,
options;
inotify = Inotify.create(true); // stand-alone, persistent mode, runs until you hit ctrl+c
//inotify = Inotify.create(); // quits when event queue is empty
directive = (function() {
// multiple events may fire at the same time
return {
create: function (ev) {
// Send the device added message to the server here
if(ev.name == 'v4l'){console.log(ev.name + " was added.");}
},
delete: function(ev) {
// Send the device removed message to teh server here
if(ev.name == 'v4l'){console.log(ev.name + " was removed.");}
}
};
}());
inotify.watch(directive, '/dev/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment