winD_unmount.sh 832 B

123456789101112131415161718
  1. #!/usr/bin/env bash
  2. winDisk="/dev/sda2"
  3. unmountingResult=$(udisksctl unmount -b $winDisk 2>&1)
  4. if [[ $? = 0 ]]
  5. then # if unmounted successfully
  6. # notify-send -i dialog-information -t 3000 "$(echo $unmountingResult | awk '{print $1 " " $2 " " $3}')" "$(echo $unmountingResult | awk '{print $4}')"
  7. notify-send -i dialog-information -t 3000 "$(echo $unmountingResult | cut -d"." -f1)"
  8. else
  9. # notify-send -i dialog-error -t 3000 " " "$(echo $unmountingResult | cut -d"'" -f1)"
  10. errHead=$(echo ${unmountingResult} | awk -F: '{print $1}')
  11. errSkip=$(echo ${unmountingResult} | cut -d" " -f4)
  12. skipLength=`expr ${#errSkip} + ${#errHead} + 2` # 2 = two spaces
  13. errTail=$(echo ${unmountingResult:$skipLength:${#unmountingResult}} | cut -d"." -f1)
  14. notify-send -i dialog-error -t 3000 "$errHead:" "$errTail"
  15. fi