Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to recognize when a USB drive-pen is plugged on linux

How to recognize when a USB drive-pen is plugged on linux

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gRicky
    wrote on 14 Oct 2013, 08:52 last edited by
    #1

    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.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 14 Oct 2013, 08:57 last edited by
      #2

      Hi,

      Does you Linux system has DBus installed ?

      157

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p3c0
        Moderators
        wrote on 14 Oct 2013, 09:05 last edited by
        #3

        Also check if there is UDisk's daemon running on the system.

        157

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gRicky
          wrote on 14 Oct 2013, 09:10 last edited by
          #4

          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?

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kuzulis
            Qt Champions 2020
            wrote on 14 Oct 2013, 09:26 last edited by
            #5

            You can use libudev also.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 14 Oct 2013, 09:27 last edited by
              #6

              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

              157

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gRicky
                wrote on 14 Oct 2013, 10:07 last edited by
                #7

                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?

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 14 Oct 2013, 10:15 last edited by
                  #8

                  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.

                  157

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gRicky
                    wrote on 14 Oct 2013, 10:18 last edited by
                    #9

                    Unfortunately the "ps" command doesn't work. Is there another way to check if the UDisk daemon is running?

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      p3c0
                      Moderators
                      wrote on 14 Oct 2013, 10:20 last edited by
                      #10

                      No similar like checking of dbus. check like this
                      @ps ax | grep -i udisk@

                      157

                      1 Reply Last reply
                      0

                      7/10

                      14 Oct 2013, 10:07

                      • Login

                      • Login or register to search.
                      7 out of 10
                      • First post
                        7/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved