Created
June 14, 2012 02:50
-
-
Save schappim/2927794 to your computer and use it in GitHub Desktop.
Node.js code to check for presence of video for linux device.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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