Bon on doit pouvoir alléger tout ça mais je ne sais pas faire, mais en tout cas mon bidule fonctionne bien
#!/bin/bash
#patrick@debian:~$ pactl list sources | grep Name:
# Name: alsa_input.pci-0000_05_01.1.analog-stereo
# Name: alsa_output.pci-0000_05_02.0.analog-surround-51.monitor
# Name: alsa_input.pci-0000_05_02.0.analog-stereo
#patrick@debian:~$
Format=( " ADCD, Mocp " " MONITOR " )
choice=$(zenity --list --radiolist --width=750 --height=300 \
--title "Avconv" \
--text="Sélectionner Un Choix" \
--column="Choix" --column="Entrée Format" \
TRUE "${Format[0]}" \
FALSE "${Format[1]}");
echo "choice=$choice"
if [ "$choice" == "${Format[0]}" ]; then
(
echo "# Enregistrement en cours..."
avconv -f alsa -ac 2 -ar 44100 -f pulse -i alsa_input.pci-0000_05_02.0.analog-stereo -acodec pcm_s16le ~/Musique/MOC-$(date +%F-%H-%M-%S).wav
) | zenity --title="Avconv" --progress --width=600 --height=50 --pulsate --auto-close &
# Get Zenity Brother Process Which is Parent of All Running Tasks
PID_ZENITY=$(ps -C zenity h -o pid,command | grep "Avconv" | awk '{print $1}')
PID_PARENT=$(ps -p ${PID_ZENITY} -o ppid=)
PID_CHILDREN=$(pgrep -d ',' -P ${PID_PARENT})
# loop to check that progress dialog has not been cancelled
while [ "$PID_ZENITY" != "" ]
do
# get PID of running processes for the children
PID_GRANDCHILDREN=$(pgrep -d ' ' -P "${PID_CHILDREN}")
# check if zenity PID is still there (dialog box still open)
PID_ZENITY=$(ps h -o pid -p ${PID_ZENITY})
# sleep for 2 second
sleep 2
done
# if some running tasks are still there, kill them
[ "${PID_GRANDCHILDREN}" != "" ] && kill -9 ${PID_GRANDCHILDREN}
fi
if [ "$choice" == "${Format[1]}" ]; then
(
echo "# Enregistrement en cours..."
avconv -ac 2 -ar 44100 -f pulse -i alsa_output.pci-0000_05_02.0.analog-surround-51.monitor -acodec pcm_s16le ~/Musique/MONITOR-$(date +%F-%H-%M-%S).wav
) | zenity --title="Avconv" --progress --width=600 --height=50 --pulsate --auto-close &
# Get Zenity Brother Process Which is Parent of All Running Tasks
PID_ZENITY=$(ps -C zenity h -o pid,command | grep "Avconv" | awk '{print $1}')
PID_PARENT=$(ps -p ${PID_ZENITY} -o ppid=)
PID_CHILDREN=$(pgrep -d ',' -P ${PID_PARENT})
# loop to check that progress dialog has not been cancelled
while [ "$PID_ZENITY" != "" ]
do
# get PID of running processes for the children
PID_GRANDCHILDREN=$(pgrep -d ' ' -P "${PID_CHILDREN}")
# check if zenity PID is still there (dialog box still open)
PID_ZENITY=$(ps h -o pid -p ${PID_ZENITY})
# sleep for 2 second
sleep 2
done
# if some running tasks are still there, kill them
[ "${PID_GRANDCHILDREN}" != "" ] && kill -9 ${PID_GRANDCHILDREN}
else
echo "Aucun Choix, Ou Quelque Chose S'est Mal Passé -- Arrêt"
exit 1
fi
Choix
Capture
Cancel
Fichier de capture dans le dossier et bien fini
Ha que je suis content !!!!
Dernière modification par Anonyme (09-09-2015 10:39:01)