How do I notify some running app of a drive being mounted by usbmount?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I'm using usbmount to mount / unmount USB drives when they are inserted / removed on my Raspbian machine. A C++ app reading MP3 files from the drive and playing them now needs to get a hint every time such a drive has been mounted (typically at /media/usb0) resp. unmounted.



Does anybody have a hint for me? Thank you.










share|improve this question


























    1















    I'm using usbmount to mount / unmount USB drives when they are inserted / removed on my Raspbian machine. A C++ app reading MP3 files from the drive and playing them now needs to get a hint every time such a drive has been mounted (typically at /media/usb0) resp. unmounted.



    Does anybody have a hint for me? Thank you.










    share|improve this question
























      1












      1








      1








      I'm using usbmount to mount / unmount USB drives when they are inserted / removed on my Raspbian machine. A C++ app reading MP3 files from the drive and playing them now needs to get a hint every time such a drive has been mounted (typically at /media/usb0) resp. unmounted.



      Does anybody have a hint for me? Thank you.










      share|improve this question














      I'm using usbmount to mount / unmount USB drives when they are inserted / removed on my Raspbian machine. A C++ app reading MP3 files from the drive and playing them now needs to get a hint every time such a drive has been mounted (typically at /media/usb0) resp. unmounted.



      Does anybody have a hint for me? Thank you.







      automounting events






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 1 at 22:54









      NeppomukNeppomuk

      1114




      1114




















          1 Answer
          1






          active

          oldest

          votes


















          0














          One quick way would be to write a script that executes usbmount on a given drive, as well as updates another data/text file, that the C++ app could poll for changes based on some time interval. Another method would be to simply include a call to your C++ app after you execute usbmount.



          Is your C++ app set to immediately autoplay files found on a given mounted USB? This might be a can of worms without very diligent input file filtering.






          share|improve this answer























          • Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

            – Neppomuk
            Mar 2 at 18:26











          • Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

            – BarBar1234
            Mar 2 at 18:53











          • No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

            – Neppomuk
            Mar 2 at 22:24











          • Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

            – BarBar1234
            Mar 2 at 22:59











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503886%2fhow-do-i-notify-some-running-app-of-a-drive-being-mounted-by-usbmount%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          One quick way would be to write a script that executes usbmount on a given drive, as well as updates another data/text file, that the C++ app could poll for changes based on some time interval. Another method would be to simply include a call to your C++ app after you execute usbmount.



          Is your C++ app set to immediately autoplay files found on a given mounted USB? This might be a can of worms without very diligent input file filtering.






          share|improve this answer























          • Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

            – Neppomuk
            Mar 2 at 18:26











          • Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

            – BarBar1234
            Mar 2 at 18:53











          • No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

            – Neppomuk
            Mar 2 at 22:24











          • Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

            – BarBar1234
            Mar 2 at 22:59















          0














          One quick way would be to write a script that executes usbmount on a given drive, as well as updates another data/text file, that the C++ app could poll for changes based on some time interval. Another method would be to simply include a call to your C++ app after you execute usbmount.



          Is your C++ app set to immediately autoplay files found on a given mounted USB? This might be a can of worms without very diligent input file filtering.






          share|improve this answer























          • Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

            – Neppomuk
            Mar 2 at 18:26











          • Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

            – BarBar1234
            Mar 2 at 18:53











          • No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

            – Neppomuk
            Mar 2 at 22:24











          • Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

            – BarBar1234
            Mar 2 at 22:59













          0












          0








          0







          One quick way would be to write a script that executes usbmount on a given drive, as well as updates another data/text file, that the C++ app could poll for changes based on some time interval. Another method would be to simply include a call to your C++ app after you execute usbmount.



          Is your C++ app set to immediately autoplay files found on a given mounted USB? This might be a can of worms without very diligent input file filtering.






          share|improve this answer













          One quick way would be to write a script that executes usbmount on a given drive, as well as updates another data/text file, that the C++ app could poll for changes based on some time interval. Another method would be to simply include a call to your C++ app after you execute usbmount.



          Is your C++ app set to immediately autoplay files found on a given mounted USB? This might be a can of worms without very diligent input file filtering.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 2 at 1:39









          BarBar1234BarBar1234

          1495




          1495












          • Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

            – Neppomuk
            Mar 2 at 18:26











          • Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

            – BarBar1234
            Mar 2 at 18:53











          • No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

            – Neppomuk
            Mar 2 at 22:24











          • Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

            – BarBar1234
            Mar 2 at 22:59

















          • Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

            – Neppomuk
            Mar 2 at 18:26











          • Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

            – BarBar1234
            Mar 2 at 18:53











          • No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

            – Neppomuk
            Mar 2 at 22:24











          • Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

            – BarBar1234
            Mar 2 at 22:59
















          Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

          – Neppomuk
          Mar 2 at 18:26





          Well, not immediately, but it's gonna play MP3 files from a stick (non-MP3 files will be excluded with a simple glob ()). Sure I can wait for a couple of seconds, but as for now, I've gotta insert the stick before launching the app, which is not feasible once the app is in production.

          – Neppomuk
          Mar 2 at 18:26













          Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

          – BarBar1234
          Mar 2 at 18:53





          Is this suppose to only be used for usb drives with specific directory structure, or once usb is inserted the app will search for any and all mp3 files on the usb device. Please clarify, the app's relatonship with the Raspberry machine. Is it a standalone app on a phone, or computer that makes a remote connection to the raspberry, or something running strictly on the raspbian as a script?

          – BarBar1234
          Mar 2 at 18:53













          No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

          – Neppomuk
          Mar 2 at 22:24





          No, the app runs locally on the Raspi and nowhere else. The stick, of course, is attached directly to the Raspi. The app will find all MP3 files residing on the stick, no matter in which directory they are.

          – Neppomuk
          Mar 2 at 22:24













          Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

          – BarBar1234
          Mar 2 at 22:59





          Can't the app simply poll at a 3s interval the path /media/usb0 path, and if any files are found, it can proceed to the search for mp3 files. and If the media/usb0 path is empty break for another 3 seconds and so on. Or better yet you can modify a udev rule to watch for new usb devices.

          – BarBar1234
          Mar 2 at 22:59

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503886%2fhow-do-i-notify-some-running-app-of-a-drive-being-mounted-by-usbmount%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown






          Popular posts from this blog

          Peggy Mitchell

          Palaiologos

          The Forum (Inglewood, California)