#!/bin/bash
#
# Toggle Energy Star off.
# It makes sense when watching movies.
#
# Author: D-M-Wilhelm
# Icons: Neal Brooks
# Tester: Neal Brooks
# Suggestions: Neal Brooks 
# Licence: GPL
# First build: Wed Dec 28 2011
# Build under PCLinuxOS-LXDE
# Copyright 2011-2015
########################################################################
ICONON="/usr/share/icons/lxdpms-on.png"
ICONOFF="/usr/share/icons/lxdpms-off.png"
TITLE=lxdpms
export TEXTDOMAIN=lxdpms
export TEXTDOMAINDIR="/usr/share/locale"

function Exit ()
{
	KI1=$(ps -ejH | grep -A2  lxdpms | grep yad | cut -d " " -f1,2)
	xset +dpms
	yad --text=$"Energy Star is enabled" --button="gtk-ok:0" \
	--window-icon="/usr/share/icons/lxdpms-on.png" --title=lxdpms
	kill $KI1
	killall lxdpms
}
export -f Exit

function Real ()
{
	xterm -hold -title $"lxdpms_real_status" -e xset q
}
export -f Real

#------------------ main -----------------------------------------------
	xset -dpms
	killall xscreensaver
	yad --window-icon=$ICONOFF --image=$ICONOFF --title=$TITLE \
	--notification --text=$"Energy Star is disabled" \
	--command='yad --title='$TITLE' --form --field '$"Turn_On:btn"' \
	--field '$"Real_Status:btn"' \
	--button="gtk-close:0" --width=200  --window-icon='$ICONON' \
	--image='$ICONON' "sh -c Exit" "sh -c Real"'
