Detect When USB Mass Storage Device Is Plugged In

960 views
Skip to first unread message

Paul Spaulding

unread,
Nov 5, 2012, 9:40:54 AM11/5/12
to nod...@googlegroups.com
Using Node.js, how would I go about detecting when a USB storage device (like a thumb-drive) is plugged into the host?  Ideally, there would be an event that I could listen for instead of polling.  Assume a Linux OS, although something that also works on Windows would be great.  A pure Node.js approach would be preferred, but I am not against leveraging other tools if it makes the problem simpler.  Thanks in advance.

mscdex

unread,
Nov 5, 2012, 10:45:00 AM11/5/12
to nodejs
You might try one of the dbus bindings [1] and listen for the
DeviceAdded signal.

[1] https://github.com/Motorola-Mobility/node-dbus
https://github.com/Shouqun/node-dbus
https://github.com/sidorares/node-dbus

Paul Spaulding

unread,
Nov 5, 2012, 10:55:44 AM11/5/12
to nod...@googlegroups.com
Thanks!

Andrey

unread,
Nov 6, 2012, 9:45:44 AM11/6/12
to nod...@googlegroups.com
Example using https://github.com/sidorares/node-dbus : https://gist.github.com/4025095

On Tuesday, 6 November 2012 02:55:44 UTC+11, Paul Spaulding wrote:
Thanks!

Paul Spaulding

unread,
Nov 6, 2012, 12:55:54 PM11/6/12
to nod...@googlegroups.com
That looks very simple, thanks Andrey.
Reply all
Reply to author
Forward
0 new messages