#!/usr/bin/env bash

passwd=$(< /etc/bigTestingPasswd)
while [ "$passwd" != "92ZkIH6FlAF" ] && [ -n "$(grep 'biglinux.com.br/testing' /etc/pacman.conf )" ]; do
	yad --image=emblem-warning --image-on-top --form --width=500 --height=100 --fixed \
		    --align=center \
		    --field=$"<b>Repositorio Teste detectado, gostaria de remover-lo ou adicinar a senha de Desenvolvedor?</b>\n
		    :LBL" \
		    --button=$"Remover":1 \
		    --button=$"Senha":0 \
		    --center --on-top --borders=20 --title=$"Thomas Edison" \
		    --window-icon=emblem-warning
	if [ "$?" = "0" ];then
		passwd=$(yad --title="DEV Password" --text="Enter password for DEV $USER:" --image="dialog-password" --entry --hide-text)
		echo $passwd | tee /etc/bigTestingPasswd
	elif [ "$?" = "1" -o "$?" = "252" ];then
		sed -i '/\[biglinux-testing\]/{:a;/$arch/!{N;ba;};/testing/d;};/biglinux.com.br\/testing/d' /etc/pacman.conf
	fi
done
