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.

1234567891011121314151617181920212223242526272829303132333435363738
  1. #! /usr/bin/env bash
  2. cdrom_status()
  3. {
  4. out=$(lshw 2>/dev/null | awk '/\*-cd/,/con/' | sed -e 's/^[ \t]*//' | grep configuration | grep -Eo 'status=[^.]+' | cut -d'=' -f2)
  5. echo $out
  6. }
  7. run_copy()
  8. {
  9. # echo "copying..."
  10. # sleep 2
  11. # copy_result=1
  12. abcde -a cddb,getalbumart,read,encode,tag,move,playlist,clean -V -x -N
  13. copy_result="$?"
  14. if [ "${copy_result}" -ne 0 ]
  15. then
  16. echo "Copy may have failed with code ${copy_result}"
  17. else
  18. echo "Copy has finished successfully"
  19. fi
  20. }
  21. old_cdrom_status=""
  22. while :
  23. do
  24. cdrom_status=$(cdrom_status)
  25. if [ "${old_cdrom_status}" != "${cdrom_status}" ] && [ "${cdrom_status}" != "" ]
  26. then
  27. echo "CDROM drive status changed: ${cdrom_status}"
  28. if [ "${cdrom_status}" == "ready" ]
  29. then
  30. run_copy
  31. fi
  32. old_cdrom_status="${cdrom_status}"
  33. fi
  34. sleep 1
  35. done