#!/bin/bash
##
account=`whoami` 
if [ ${account} != "pcscale" ]; then
	zenity --error --title "Customizing..." --text "You have executed this program as sudo.\nYou must execute it without sudo"
	echo ' '
	echo ' '
	exit 1
fi
echo ---------------------------------------
echo "Enabling Fiscal France"
echo ---------------------------------------

FiscalFrance(){
	fiscal=$(gsettings get com.grupoepelsa.TouchScale.config france-status)
	if [ "$fiscal" = "'0'" ];then  
	
		clave=$(zenity --entry --title="FISCAL FRANCE" --text="Type the password" --entry-text "password" --hide-text)
			if [ "$clave" != "epelsa" ]; then
				zenity --info --title="FISCAL FRANCE" --text "wrong password" --timeout 10
				exit 1
							
			else
				var= zenity --question --title="FISCAL FRANCE IS DISABLED" --text="This will ENABLE Fiscal France features\n Are You sure?" --timeout 10
					if [ $? -eq 1 ]; then
						#"Nos salimos sin hacer nada"
						zenity --info --title="FISCAL FRANCE" --text "Whitout changes" --timeout 10
					else
						#"Modificamos el valor a 1"
						gsettings set com.grupoepelsa.TouchScale.config france-status 1
						zenity --info --title="FISCAL FRANCE" --text "Fiscal France is now Enable" --timeout 10
						Restart
					fi
			fi
	else 
		zenity --info --title="FISCAL FRANCE" --text "Fiscal France is already Enable" --timeout 10
	fi	
}
Restart(){
	if pgrep pcscale > /dev/null; then
		killall pcscale
		export DISPLAY=:0
		cd /usr/bin
		pcscale main &
	fi
}
FiscalFrance
exit 1
