How to recognize when a USB drive-pen is plugged on linux
-
wrote on 14 Oct 2013, 08:52 last edited by
Hi guys,
I need to understand when a user plugs a USB drive-pen to a linux pc. Is there a simple method to recognize this event? Does the operating system signal this event? In the case the operating system signalled the plug of the USB event, how can I intercept this signal?Thank you in advance.
-
Hi,
Does you Linux system has DBus installed ?
-
Also check if there is UDisk's daemon running on the system.
-
wrote on 14 Oct 2013, 09:10 last edited by
I'm using a subversion of a linux and actually I don't know if a DBus is already installed. Do you know how can I check if it is installed? How DBus can help me?
-
You can use libudev also.
-
You can check DBus by checking process as,
@ps ax | grep -i dbus@If you get output like "dbus-daemon --system --fork" then DBus is running on your system
The UDisks package provides a storage daemon that can be used to query and manipulate storage devices.
It exposes some DBus interfaces which can be used.
You can read more "here":http://www.freedesktop.org/wiki/Software/udisks/.Qt has DBus support which means you can access and hook into the DBus interfaces that are provided by UDisk.
Read more here > "qtdbus":http://qt-project.org/doc/qt-5.0/qtdbus/qtdbus-index.html.qdbusviewer is a Qt tool to check what DBus services are running on your system. There you can see in the System Bus if UDisk is running.
You can check on you machine if you have qdbusviewer installed or you can compile and install it.Explore it more in the right side pane
-
wrote on 14 Oct 2013, 10:07 last edited by
I've check if the DBus is installed on my PC using the line you have suggested using:
[quote author="p3c0" date="1381742876"]You can check DBus by ,
@ps ax | grep -i dbus@
[/quote]It seems the DBus is already running because I got back an answer like:
*"dbus-daemon --system --fork"The answer gave me more information: the busybox is running on the machine and this is ok for my purpose then, does the qtdbus works even if the dbus is working with busybox system?
-
It must work with the busybox.
Also did you check if the UDisk daemon is running ? Run "ps" and check if you get output something like this "/usr/lib/udisks2/udisksd --no-debug"
If it is running then just install and run qdbusviewer. -
wrote on 14 Oct 2013, 10:18 last edited by
Unfortunately the "ps" command doesn't work. Is there another way to check if the UDisk daemon is running?
-
No similar like checking of dbus. check like this
@ps ax | grep -i udisk@
7/10