My build of nnn with minor changes
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.
 
 
 
 
 
 

37 lines
890 B

  1. #!/usr/bin/env sh
  2. # Description: Toggle mount status of a device using pmount
  3. # If the device is not mounted, it will be mounted.
  4. # If the device is mounted, it will be unmounted and powered down.
  5. #
  6. # Shell: POSIX compliant
  7. # Author: Arun Prakash Jana
  8. lsblk
  9. echo
  10. echo "Make sure you aren't still in the mounted device."
  11. echo -n "device (e.g. sdc2): "
  12. read dev
  13. while ! [ -z "$dev" ]
  14. do
  15. if grep -qs "$dev " /proc/mounts; then
  16. sync
  17. pumount "$dev"
  18. if [ "$?" -eq "0" ]; then
  19. echo "$dev" unmounted.
  20. udisksctl power-off -b /dev/"$dev"
  21. if [ "$?" -eq "0" ]; then
  22. echo "$dev" ejected.
  23. fi
  24. fi
  25. else
  26. pmount "$dev"
  27. echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)".
  28. fi
  29. echo
  30. echo -n "next device: "
  31. read dev
  32. done