umount.sh 556 B

12345678910111213141516171819202122232425262728
  1. #!/bin/sh
  2. mounted_devices=()
  3. for devlink in /dev/disk/by-id/usb*; do
  4. dev=`readlink -f ${devlink}`
  5. is_mounted=$(mount | grep $dev)
  6. if [[ "$is_mounted" != "" ]]; then
  7. echo "Device $dev mounted"
  8. mounted_devices+=($dev)
  9. fi
  10. done
  11. if [ ${#mounted_devices[@]} -eq 0 ];
  12. then
  13. echo "Nothing to do, exiting"
  14. exit 1
  15. fi
  16. IFS=$'\n';
  17. umount=$(printf "%s\n" ${mounted_devices[@]} | dmenu -l 3)
  18. if [ "$umount" != "" ]; then
  19. echo "unmounting device $umount"
  20. udiskie-umount $umount
  21. else
  22. echo "Nothing to do, exiting"
  23. fi