#!/bin/bash
USER=$(whoami)

(
echo "#Antes de comenzar el test de Velocidad comprobaremos la conexión con Internet ..."
if ping -c 1 8.8.8.8 &> /dev/null ; then
	echo "#¡¡Ok!! Hay conexión con Internet ...\nEn breve comenzará el test y obtendremos un resultado ... ¡¡Ten paciencia!!"
	/usr/bin/vx-test-velocidad-cli | tee /tmp/resultado-test-velocidad | sed -e "s/.*/#&/g"
	DOWNLOAD=$(cat /tmp/resultado-test-velocidad | grep Download | cut -d":" -f2)
	UPLOAD=$(cat /tmp/resultado-test-velocidad | grep Upload | cut -d":" -f2)
	echo "#Velocidad Descarga: $DOWNLOAD - Velocidad Subida: $UPLOAD"
else
	echo "#Problema!! Parece que no hay conexión con Internet ...\nNo se puede realizar el Test de Velocidad ..."
fi
) | yad \
	--title "Test de Velocidad de Internet: Download & Upload" \
	--window-icon vitalinux \
	--width 650 \
	--center \
	--progress \
	--pulsate --button="Cerrar Ventana":0

exit 0

