2

I forgot my pendrive plugged in when leaving the computer lab yesterday, and I would have lost it if it wasn't for a kind soul finding and returning it. I want to avoid this in the future and apparently there are some tools you can use in windows that warn you if you are leaving a pendrive behind when logging off or shutting down the computer. Is there anything similar that works on Linux?

I need this to work on Fedora 17 (GNOME 3 shell), and preferably without requiring administrator privileges.

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
hugomg
  • 699

1 Answers1

1

You can create a logoff script (see Create a logoff script/task for Linux) which checks if a usb disk is currently used. That could be done doing something like

if [ `lsmod | grep usb_storage | grep -o -E [0-9]+[[:space:]]*$` -gt 0 ]; then echo -e "\a\a\a\a"; fi 

This command will determine if a USB drive is connected by testing the number of devices using the usb_storage module and ring the bell 4 times if any are still connected. You may choose to do something else instead, such as unmounting, but bear in mind that you are logging off at that point so options are limited.