dotfiles

Cem's Dotfiles
git clone git://git.ckyln.com/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

dmenuumount (678B)


      1 #!/usr/bin/env sh
      2 # A dmenu prompt to unmount drives.
      3 # Provides you with mounted partitions, select one to unmount.
      4 # Drives mounted at /, /boot and /home will not be options to unmount.
      5 
      6 unmountusb() {
      7 	[ -z "$drives" ] && exit
      8 	chosen=$(echo "$drives" | dmenu -l 15 -i -p "Unmount which drive?" | awk '{print $1}')
      9 	[ -z "$chosen" ] && exit
     10 	sudo -A umount -R "$chosen" && notify-send "USB unmounting" "$chosen unmounted."
     11 	}
     12 
     13 drives=$(lsblk -nrpo "name,type,size,mountpoint" | awk '$2=="part"&&$4!~/\/boot|\/home$|SWAP/&&length($4)>1{printf "%s (%s)\n",$4,$3}')
     14 
     15 [ -z "$drives" ] && echo "No drives to unmount." &&  exit
     16 echo "Unmountable USB drive detected."
     17 unmountusb