You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.4 KiB

  1. #!/bin/bash
  2. COLS="name,type,size,mountpoint"
  3. if [[ "$1" == "unmount" ]]
  4. then
  5. drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4!=""{printf "%s (%s)\n",$1,$3}')"
  6. [ -z "$drives" ] && exit 1
  7. chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to unmount: ' | awk '{print $1}')"
  8. [ -z "$chosen" ] && exit 1
  9. umount $chosen && notify-send "$chosen umounted" || notfiy-send "Error unmounting $chosen"
  10. else
  11. drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')"
  12. [ -z "$drives" ] && exit 1
  13. chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to mount: ' | awk '{print $1}')"
  14. [ -z "$chosen" ] && exit 1
  15. mount "$chosen" && exit 0
  16. mp="$(find /mnt /media /mount /home -type d -maxdepth 1 2>/dev/null | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point: ' | awk '{print $1}')"
  17. [ "$mp" = "" ] && exit 1
  18. if [ ! -d "$mp" ]; then
  19. mkdiryn=$(printf "No\\nYes" | dmenu -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point does not exist, create it?')
  20. [ "$mkdiryn" = "Yes" ] && sudo -A mkdir -p "$mp"
  21. fi
  22. echo $mp
  23. mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp." || notify-send "Error mounting $chosen to $mp"
  24. fi