My *nix world

X11 monitor usb storage

I am using Gentoo with XFce desktop environment. I would like to get notified each time a new USB storage is attached/removed. I am sure that there exists applets/plugins that do that but I would like it to keep it simple. What could be simpler than a bash script that you can write by your self?

So I came up with the following solution:

  • write a simple bash script (eg: monitor_usb-storage) which will check every 5 seconds if a new scsi/usv-storage have been attached and was registered in the /proc, and if it does then a notify balloon will be shown. The same thing when the device is removed.
  • set up that script to be automatically launched at session start-up

Monitor usb storage - a working solution

How my script looks like:


Start monitor_usb-storage as daemon at session start-up

In Xfce you can set up a Application Autostart (which are supposed to start at session start up):

  • Settings -> Session and Startup -> Application Autostart tab
  • define a new application autostart as bellow:
    • name: monitor_usb-storage (in fact it doesn't matter how you will name it)
    • command: monitor_usb-storage

So, the daemon will start when your X session starts and then will monitor the new usb-storage attached/removed every 5 seconds. When new device attached/removed then a balloon notification like the one bellow will be shown:

monitor usb storage

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

 
The following two tabs change content below.
X11 monitor usb storage

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Tagged on: ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Follow

Get every new post on this blog delivered to your Inbox.

Join other followers: