0

My question is simple, is there a way to see in a terminal what usb devices do I have connected to my computer in real time? I already know lsusb, but it just show me the devices on the moment I ask it, I would like to be able to see if one connects and disconects at some point.

Edit: Thought the answer marked underneath gives a good alternative, in order to debug the program I was working on I found usefull useing the C++ function

std::system("lsusb");

This way I could check if I had lost or not the USB device.

Sxubach
  • 364
  • 1
  • 2
  • 13

1 Answers1

1

Sure there is, you can use the udev device manager for kernel.

Moreover you can define rules to detect plugged/unplugged devices you are interested e.g. in your case usb devices.

Here is a tutorial on how to write a udev rule

deimus
  • 9,565
  • 12
  • 63
  • 107
  • Ok, I followed that awesome tutorial and added to the rule I was using (to change the permisions) a RUN so it can execute a script wich notifys me. The problem now is the script, because it seems that the way that blog uses its not longer working. How do I notify to myself that I have, infact pluged an USB? I am using the notify-send comand they explain, but as the one lauching the script is the Root it don't apear, do you know how to fix it? And also, can I through udev rules check when somthing is unpluged from the PC? – Sxubach Jan 27 '15 at 17:19
  • What exactly is not working, please provide more info ? the blog also contains instructions related to `notify-send` issue workaround. Of course with `udev` you can also detect the unplugged usb devices. – deimus Jan 28 '15 at 08:16
  • The work arround seems to be outdated. For what I found in the internet the gnome-panel is no longer used and it is how they used to fix it. Do you know if someone did update on that work arround? Right now I am reading on DBUS which to me seems to be the key element of that work arround. – Sxubach Jan 28 '15 at 09:27
  • `gnome-panel` has nothing to do with your problem ! You don't have to do anything with `gnome-panel` ! You have the script running, thats it, so you are able to detect plugged/unplugged devices. Why are you diving into `notify-send` or `Dbus` ? Of course you can achieve more elegant solutions with `dbus` notification service, but I think its out of your question scope here. – deimus Jan 28 '15 at 10:56
  • The point is that, provably because I am short in imagination, once i detect with the udev if my device is pluged in and run a script, I don't know what to do with the script to actually see it as a user (as the original purpose of this is pure debuging). Given this I thought that apart from debuging, if I where to do this nice enough this could be a good userfriendly add-on to my driver – Sxubach Jan 28 '15 at 11:09
  • if you want to have some user-friendly way of notification, just go ahead into the `dbus`, it provides a really nice technique for communication between the applications/processes. – deimus Jan 28 '15 at 11:24
  • For anyone interested on this subject, I continued asking in this other question: (http://stackoverflow.com/questions/28195805/runing-notify-send-as-root) – Sxubach Jan 29 '15 at 10:33