1234567891011121314151617181920212223242526272829303132333435363738 |
- #! /usr/bin/env bash
-
- cdrom_status()
- {
- out=$(lshw 2>/dev/null | awk '/\*-cd/,/con/' | sed -e 's/^[ \t]*//' | grep configuration | grep -Eo 'status=[^.]+' | cut -d'=' -f2)
- echo $out
- }
-
- run_copy()
- {
- # echo "copying..."
- # sleep 2
- # copy_result=1
- abcde -a cddb,getalbumart,read,encode,tag,move,playlist,clean -V -x -N
- copy_result="$?"
- if [ "${copy_result}" -ne 0 ]
- then
- echo "Copy may have failed with code ${copy_result}"
- else
- echo "Copy has finished successfully"
- fi
- }
-
- old_cdrom_status=""
- while :
- do
- cdrom_status=$(cdrom_status)
- if [ "${old_cdrom_status}" != "${cdrom_status}" ] && [ "${cdrom_status}" != "" ]
- then
- echo "CDROM drive status changed: ${cdrom_status}"
- if [ "${cdrom_status}" == "ready" ]
- then
- run_copy
- fi
- old_cdrom_status="${cdrom_status}"
- fi
- sleep 1
- done
|