winD_mount.sh 720 B

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