I don't know if this issue is solve but i have made a script using zenity progress fully functional.
The script makes a backup file. The progress bar also works fine, it shows the exact percentage of the copy and if you press the cancel button close the zenity window and kill the copy process. I hope this would help to someone.
if [ "$?" = 1 ] ; then
pidC="$(pidof cp)"
kill $pidC
rm -v $destino
zenity --info --width=300 height--200 --title="Borrar Backup" --text="El proceso numero $pidC ha sido destruido.\n\nEl archivo $destino ha sido borrado."
fi
P.D. I'm from Mexico, thats why the labels and the variable's names are in spanish. Hope doesn't matter.
I don't know if this issue is solve but i have made a script using zenity progress fully functional.
The script makes a backup file. The progress bar also works fine, it shows the exact percentage of the copy and if you press the cancel button close the zenity window and kill the copy process. I hope this would help to someone.
Here's a copy of the code i wrote.
#!/bin/bash
fuente= ~/.VirtualBox/ XP.vdi ~/.VirtualBox/ XP.vdi. backup
destino=
size="$(ls -l ~/.VirtualBox/ XP.vdi | awk '{print $5}')"
copy=0
cp $fuente $destino &
while [ $copy -lt $size ]
do
sleep 1
porcentaje="$( echo "scale = 5 ; $copy / $size * 100 " | bc )"
echo "#Copiando $copy bytes. Tamaño total: $size bytes."
echo $porcentaje
copy="$(ls -l $destino | awk '{print $5}')"
done | zenity --progress --width=350 --title='Creando XP.vdi.backup'
if [ "$?" = 1 ] ; then
pidC="$(pidof cp)"
kill $pidC
rm -v $destino
zenity --info --width=300 height--200 --title="Borrar Backup" --text="El proceso numero $pidC ha sido destruido.\n\nEl archivo $destino ha sido borrado."
fi
P.D. I'm from Mexico, thats why the labels and the variable's names are in spanish. Hope doesn't matter.