#!/bin/bash

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

# (c) Antonio Sánchez León <introlinux[fix@]gmail[fix.]com>
# (c) Miguel Anxo Bouzada <mbouzada[fix@]gmail[fix.]com>
# (c) GALPon MinNo Team <minino[fix@]galpon[fix.]org>
# july 2012

## -

case $LANG in
	ca*)
		TITLE1="Estalvi d'energia"
		TEXT1="Si desactiveu el apagat automàtic, la
pantalla romandrà sempre encesa.

En els portàtils seguirà consumint bateria.
"
		SIN=" Desactivar l'apagat de la pantalla"
		CON=" Activar l'apagat de la pantalla"
		PRL=" Modificar el temps d'espera"
		TITLE2="Modificar el temps"
		TEXT2=" Introduïu el temps en <b>segons</b> 
	<b>300</b> = 5 minuts
	<b>600</b> = 10 minuts"
		;;
	es*)
		TITLE1="Ahorro de energía"
		TEXT1="Si desactiva el apagado automático, la
pantalla permanecerá siempre encendida.

En los potátiles seguirá consumiendo batería.
"
		SIN=" Desactivar el apagado de la pantalla"
		CON=" Activar el apagado de la pantalla"
		PRL=" Modificar el tiempo de espera"
		TITLE2="Modificar el tiempo"
		TEXT2=" Introduzca el tiempo en <b>segundos</b> 
	<b>300</b> = 5 minutos
	<b>600</b> = 10 minutos"
		;;
	gl*)
		TITLE1="Aforro de enerxía"
		TEXT1="Se desactiva o apagado automático, a
pantalla permanecerá sempre acendida.

Nos potátiles seguirá a consumir batería.
"
		SIN=" Desactivar o apagado de pantalla"
		CON=" Activar o apagado de pantalla"
		PRL=" Modificar o tempo de espera"
		TITLE2="Modificar tempo"
		TEXT2=" Introduza o tempo en <b>segundos</b> 
	<b>300</b> = 5 minutos
	<b>600</b> = 10 minutos"
		;;
	*)
		TITLE1="Power saving"
		TEXT1="If screen auto power off is disabled, screen
will always stay on. This option is not good for saving batery in laptops.
"
		SIN=" Disable auto screen off"
		CON=" Enable auto screen off"
		PRL=" Modify timeout for auto screen off"
		TITLE2="Modify timeout"
		TEXT2=" Enter timeout in <b>seconds</b> 
	<b>300</b> = 5 minutes
	<b>600</b> = 10 minutes"
		;;
esac

function modificaTiempo(){
	TIEMPO=$(yad --entry --numeric\
		--window-icon screensaver \
		--title "$TITLE2" \
		--text "$TEXT2" \
		--entry-text "600")
	xset dpms $TIEMPO $TIEMPO $TIEMPO
}

MODO=$(yad --window-icon screensaver --title "$TITLE1" --text "$TEXT1" \
	--list --print-column 1 --no-headers \
	--image screensaver --width 330 --height 220 \
	--column "control" --column "acción":tip --hide-column 1 \
    con "$CON" \
    sin "$SIN" \
    prl "$PRL" )

case $MODO in
	con*)
		# Activamos DPMS
		#xset dpms 600 600 600
		xset +dpms
		
		;;
	sin*)	
		# Desactivamos DPMS
		xset -dpms
		#xset dpms 0 0 0
		#xset s reset
		#xset s off -dpms
		;;
	prl*)
		#Ejecutamos función
		modificaTiempo
		;;
	*) exit 1 ;;
esac
