#!/bin/bash
#***********************************************************************
# compton_settings simple script to manage compton
# Generate under PCLinuxOS-LXDE for LXDE-Sessions
# Author: Daniel Meiß-Wilhelm (leiche) 
# Lincence: GPL
# Web site: www.pclinuxos.com/forum
# Required: bash compton compton_start gtkdialog
#***********************************************************************
export TEXTDOMAIN=compton_settings
export TEXTDOMAINDIR="/usr/share/locale"
#
# some variables
#
CONF_DIR=~/.compton
INFO=`cat "$CONF_DIR/main"`
TITLE=compton-start
VERSION=0.11
ICON=/usr/share/pixmaps/xcomp.png
IMAGE="/usr/share/doc/lxautostart/Image.png"
#
#create directory and files for first running of compton_settings
if [ -d $CONF_DIR ];then echo -e $"$CONF_DIR directory found\n\n"; 
	else 
		if [ ! -d $HOME/.compton ]; then mkdir $HOME/.compton ;fi 
		mkdir $CONF_DIR && echo $"Creating directory $CONF_DIR " && if \
		[ -d $CONF_DIR ];then echo $"Done" || echo -e $"$CONF_DIR directory could not be created\n\n"; fi
	fi

RUN=`ps -e | grep -w compton | cut -d ":" -f3 | cut -d " " -f2`
#
# check if compton running
#
if [ "$RUN" = "compton" ];then
	echo $"compton is running."
	STATUS=$"Active"
	XSTART=false
	XSTOP=true
	else
	STATUS=$"Inactive"
	XSTART=true
	XSTOP=false
fi
#
#check status
#
{
if [ -f ~/.config/autostart/compton_start.desktop ];then
	echo $"Enable" > $CONF_DIR/status
	AUTO=`cat $CONF_DIR/status`
	AUTOSTART=false
	AUTOSTOP=true
	else
	echo $"Disable" > $CONF_DIR/status
	AUTO=`cat $CONF_DIR/status`
	AUTOSTART=true
	AUTOSTOP=false
fi
if [ ! -f $CONF_DIR/s31 ]; then
	ST30=false
	ST31="?"
else		
	if [ $(grep -c - "$CONF_DIR"/s31) -gt 0 2>/dev/null ]; then   
		ST30=true
		ST31=`cat $CONF_DIR/s31`
		else
		ST30=false
		ST31="?"
	fi
fi	
if [ ! -f $CONF_DIR/s01 ]; then
	ST01=false
	else	
	ST01=`cat $CONF_DIR/s01`
fi
if [ ! -f $CONF_DIR/s02 ]; then
	ST02=false
	else
	ST02=`cat $CONF_DIR/s02`
fi
if [ ! -f $CONF_DIR/s03 ]; then
	ST03=false
	else
	ST03=`cat $CONF_DIR/s03`
fi
if [ ! -f $CONF_DIR/s04 ]; then
	ST04=false
	else
	ST04=`cat $CONF_DIR/s04`
fi
if [ ! -f $CONF_DIR/s0 ]; then
	ST0=false
	else
	ST0=`cat $CONF_DIR/s0`
fi
if [ ! -f $CONF_DIR/s1 ]; then
	ST1=false
	else
	ST1=`cat $CONF_DIR/s1`
fi
if [ ! -f $CONF_DIR/s2 ]; then
	ST2=false
	else
	ST2=`cat $CONF_DIR/s2`
fi
if [ ! -f $CONF_DIR/s3 ]; then
	ST3=false
	else
	ST3=`cat $CONF_DIR/s3`
fi
if [ ! -f $CONF_DIR/s4 ]; then
	ST4=false
	else
	ST4=`cat $CONF_DIR/s4`
fi
if [ ! -f $CONF_DIR/s5 ]; then
	ST5=false
	else
	ST5=`cat $CONF_DIR/s5`
fi
if [ ! -f $CONF_DIR/s6 ]; then
	ST6=false
	else
	ST6=`cat $CONF_DIR/s6`
fi
if [ ! -f $CONF_DIR/s7 ]; then
	ST7=false
	else
	ST7=`cat $CONF_DIR/s7`
fi
if [ ! -f $CONF_DIR/s24 ]; then
	ST24=false
	else
	ST24=`cat $CONF_DIR/s24`
fi
if [ ! -f $CONF_DIR/s25 ]; then
	ST25="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s25) -gt 0 2>/dev/null ]; then 
		ST25=`cat $CONF_DIR/s25`
		else
		ST25="?"
	fi
fi
if [ ! -f $CONF_DIR/s26 ]; then
	ST26=false
	else
	ST26=`cat $CONF_DIR/s26`
fi
if [ ! -f $CONF_DIR/s27 ]; then
	ST27="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s27) -gt 0 2>/dev/null ]; then 
		ST27=`cat $CONF_DIR/s27`
		else
		ST27="?"
	fi	
fi
if [ ! -f $CONF_DIR/s28 ]; then
	ST28=false
	else
	ST28=`cat $CONF_DIR/s28`
fi
if [ ! -f $CONF_DIR/s29 ]; then
	ST29="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s29) -gt 0 2>/dev/null ]; then 
		ST29=`cat $CONF_DIR/s29`
		else
		ST29="?"
	fi
fi
if [ ! -f $CONF_DIR/s8 ]; then
	ST8=false
	else
	ST8=`cat $CONF_DIR/s8`
fi
if [ ! -f $CONF_DIR/s9 ]; then
	ST9="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s9) -gt 0 2>/dev/null ]; then 
		ST9=`cat $CONF_DIR/s9`
		else
		ST9="?"
	fi	
fi
if [ ! -f $CONF_DIR/s10 ]; then
	ST10=false
	else
	ST10=`cat $CONF_DIR/s10`
fi
if [ ! -f $CONF_DIR/s11 ]; then
	ST11="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s11) -gt 0 2>/dev/null ]; then 
		ST11=`cat $CONF_DIR/s11`
		else
		ST11="?"
	fi	
fi
if [ ! -f $CONF_DIR/s12 ]; then
	ST12=false
	else
	ST12=`cat $CONF_DIR/s12`
fi
if [ ! -f $CONF_DIR/s13 ]; then
	ST13="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s13) -gt 0 2>/dev/null ]; then 
		ST13=`cat $CONF_DIR/s13`
		else
		ST13="?"
	fi	
fi
if [ ! -f $CONF_DIR/s14 ]; then
	ST14=false
	else
	ST14=`cat $CONF_DIR/s14`
fi
if [ ! -f $CONF_DIR/s15 ]; then
	ST15="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s15) -gt 0 2>/dev/null ]; then 
		ST15=`cat $CONF_DIR/s15`
		else
		ST15="?"
	fi	
fi
if [ ! -f $CONF_DIR/s16 ]; then
	ST16=false
	else
	ST16=`cat $CONF_DIR/s16`
fi
if [ ! -f $CONF_DIR/s17 ]; then
	ST17="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s17) -gt 0 2>/dev/null ]; then 
		ST17=`cat $CONF_DIR/s17`
		else
		ST17="?"
	fi
fi
if [ ! -f $CONF_DIR/s18 ]; then
	ST18=false
	else
	ST18=`cat $CONF_DIR/s18`
fi
if [ ! -f $CONF_DIR/s19 ]; then
	ST19="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s19) -gt 0 2>/dev/null ]; then 
		ST19=`cat $CONF_DIR/s19`
		else
		ST19="?"
	fi	
fi
if [ ! -f $CONF_DIR/s20 ]; then
	ST20=false
	else
	ST20=`cat $CONF_DIR/s20`
fi
if [ ! -f $CONF_DIR/s21 ]; then
	ST21="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s21) -gt 0 2>/dev/null ]; then 
		ST21=`cat $CONF_DIR/s21`
		else
		ST21="?"
	fi	
fi
if [ ! -f $CONF_DIR/s22 ]; then
	ST22=false
	else
	ST22=`cat $CONF_DIR/s22`
fi
if [ ! -f $CONF_DIR/s23 ]; then
	ST23="?"
	else
	if [ $(grep -c . "$CONF_DIR"/s23) -gt 0 2>/dev/null ]; then 
		ST23=`cat $CONF_DIR/s23`
		else
		ST23="?"
	fi	
fi

}
#
# read settings
#
function read_settings(){
	if [ -f $CONF_DIR/s01 ]; then S01=$(cat $CONF_DIR/s01); fi
	if [ "$S01" == "true" ]; then 
	SX01="-cC -i 0.6 -e 0.6"; fi
	
	if [ -f $CONF_DIR/s02 ]; then S02=$(cat $CONF_DIR/s02); fi
	if [ "$S02" == "true" ]; then 
	SX02="-cC -i 0.6 -e 0.6 -fF"; fi
	
	if [ -f $CONF_DIR/s03 ]; then S03=$(cat $CONF_DIR/s03); fi
	if [ "$S03" == "true" ]; then 
	SX03="-cC -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6"; fi
	
	if [ -f $CONF_DIR/s04 ]; then S04=$(cat $CONF_DIR/s04); fi
	if [ "$S04" == "true" ]; then 
	SX04="-cCGfF -o 0.38 -O 200 -I 200 -t 0.02 -l 0.02 -r 3.2 -D2 -m 0.88"; fi
	
	if [ -f $CONF_DIR/s0 ]; then S0=$(cat $CONF_DIR/s0); fi
	if [ "$S0" == "true" ]; then SX0="-b"; fi

	if [ -f $CONF_DIR/s1 ]; then S1=$(cat $CONF_DIR/s1); fi
	if [ "$S1" == "true" ]; then SX1="-c"; fi
	
	if [ -f $CONF_DIR/s2 ]; then S2=$(cat $CONF_DIR/s2); fi
	if [ "$S2" == "true" ]; then SX2="-C"; fi
	
	if [ -f $CONF_DIR/s3 ]; then S3=$(cat $CONF_DIR/s3); fi
	if [ "$S3" == "true" ]; then SX3="-f"; fi
	
	if [ -f $CONF_DIR/s4 ]; then S4=$(cat $CONF_DIR/s4); fi
	if [ "$S4" == "true" ]; then SX4="-F"; fi	
	
	if [ -f $CONF_DIR/s5 ]; then S5=$(cat $CONF_DIR/s5); fi
	if [ "$S5" == "true" ]; then SX5="-G"; fi
	
	if [ -f $CONF_DIR/s6 ]; then S6=$(cat $CONF_DIR/s6); fi
	if [ "$S6" == "true" ]; then SX6="-z"; fi
	
	if [ -f $CONF_DIR/s7 ]; then S7=$(cat $CONF_DIR/s7); fi
	if [ "$S7" == "true" ]; then SX7="-S"; fi	
	
	if [ -f $CONF_DIR/s8 ]; then S8=$(cat $CONF_DIR/s8); fi
	if [ "$S8" == "true" ]; then SX8="-d "; fi
	
	if [ -f $CONF_DIR/s9 ]; then SX9=$(cat $CONF_DIR/s9); fi
	
	if [ -f $CONF_DIR/s10 ]; then S10=$(cat $CONF_DIR/s10); fi
	if [ "$S10" == "true" ]; then SX10="-r"; fi
	
	if [ -f $CONF_DIR/s11 ]; then SX11=$(cat $CONF_DIR/s11); fi
	
	if [ -f $CONF_DIR/s12 ]; then S12=$(cat $CONF_DIR/s12); fi
	if [ "$S12" == "true" ]; then SX12="-o"; fi
	
	if [ -f $CONF_DIR/s13 ]; then SX13=$(cat $CONF_DIR/s13); fi
	
	if [ -f $CONF_DIR/s14 ]; then S14=$(cat $CONF_DIR/s14); fi
	if [ "$S14" == "true" ]; then SX14="-l"; fi
	
	if [ -f $CONF_DIR/s15 ]; then SX15=$(cat $CONF_DIR/s15); fi
	
	if [ -f $CONF_DIR/s16 ]; then S16=$(cat $CONF_DIR/s16); fi
	if [ "$S16" == "true" ]; then SX16="-t"; fi
	
	if [ -f $CONF_DIR/s17 ]; then SX17=$(cat $CONF_DIR/s17); fi	
	
	if [ -f $CONF_DIR/s18 ]; then S18=$(cat $CONF_DIR/s18); fi
	if [ "$S18" == "true" ]; then SX18="-I"; fi
	
	if [ -f $CONF_DIR/s19 ]; then SX19=$(cat $CONF_DIR/s19); fi
	
	if [ -f $CONF_DIR/s20 ]; then S20=$(cat $CONF_DIR/s20); fi
	if [ "$S20" == "true" ]; then SX20="-O"; fi
	
	if [ -f $CONF_DIR/s21 ]; then SX21=$(cat $CONF_DIR/s21); fi	
	
	if [ -f $CONF_DIR/s22 ]; then S22=$(cat $CONF_DIR/s22); fi
	if [ "$S22" == "true" ]; then SX22="-D"; fi
	
	if [ -f $CONF_DIR/s23 ]; then SX23=$(cat $CONF_DIR/s23); fi
	
	if [ -f $CONF_DIR/s24 ]; then S24=$(cat $CONF_DIR/s24); fi
	if [ "$S24" == "true" ]; then SX24="-m "; fi
	
	if [ -f $CONF_DIR/s25 ]; then SX25=$(cat $CONF_DIR/s25); fi
	
	if [ -f $CONF_DIR/s26 ]; then S26=$(cat $CONF_DIR/s26); fi
	if [ "$S26" == "true" ]; then SX26="-i "; fi
	
	if [ -f $CONF_DIR/s27 ]; then SX27=$(cat $CONF_DIR/s27); fi
	
	if [ -f $CONF_DIR/s28 ]; then S28=$(cat $CONF_DIR/s28); fi
	if [ "$S28" == "true" ]; then SX28="-e "; fi
	
	if [ -f $CONF_DIR/s29 ]; then SX29=$(cat $CONF_DIR/s29); fi
	
	if [ -f $CONF_DIR/s31 ]; then SX31=$(cat $CONF_DIR/s31); fi

	#create a history file
	cat $CONF_DIR/main >> $CONF_DIR/history
	#read and set new setting
	echo $SX01 $SX0 $SX1 $SX2 $SX3 $SX4 $SX5 $SX6 $SX7 $SX8 $SX9 \
	$SX10 $SX11 $SX12 $SX13 $SX14 $SX15 $SX16 $SX17 $SX18 $SX19 \
	$SX20 $SX21 $SX22 $SX23 $SX24 $SX25 $SX26 $SX27 $SX28 $SX29 \
	$SX02 $SX03 $SX31 $SX04 > $CONF_DIR/main 
}	
#
# about dialog
#
{
export ABOUT='
<window title="compton-settings" resizable="false" icon-name="help-about">
<vbox>
    <frame>
      <text use-markup="True" width-chars="30">
        <label>"<span color='"'blue'"'><span font-size='"'xx-large'"'><b>compton-settings</b></span></span>"</label>
      </text>
      <text use-markup="True" width-chars="30">
        <label>"<b>Version:</b> '"$VERSION"'"</label>
      </text>
      <text>
        <label>'$"Created for"'</label>
      </text>
      <text use-markup="True">
      <label>"<span color='"'red'"'><span font-size='"'xx-large'"'><b>PCLinuxOS-LX**</b></span></span>"</label>
	  </text>
      <text>
        <label>**************************************************</label>
      </text>    
      <text>
        <label>'$"compton_settings is a simple gui to manage compton commands"'</label>
      </text>
      <text use-markup="True" width-chars="30">
        <label>"<b>'$"A command looks as sample:</b>"'"</label>
      </text>
      <text>  
        <label>'"compton -cC -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6 "'</label>
      </text>
      <text>
        <label>**************************************************</label>
      </text>    
      <text use-markup="True" width-chars="30">  
        <label>"'$"<b>Author:</b> D.M-Wilhelm [leiche]"'"</label>
      </text>
      <text>
        <label>'$"Released 2012-2015"'</label>
      </text>
      <text>
        <label>'$"Under GPL License"'</label>
      </text>
      <text use-markup="True">
        <label>"'$"<b>Translators are:</b> ghostbunny (DE)"'"</label>
      </text>
      <text use-markup="True" width-chars="30">
        <label>"'$"<a href='http://www.pclinuxos.com'>PCLinuxOS Web Site</a>"'"</label>
      </text>
       <button>
        <label>OK</label>
         <variable>ABOUT</variable>
          <action type="closewindow">ABOUT</action>
      </button>
    </frame>
  </vbox>
</window>
'
}
#
# main dialog
#
{
export MAIN_DIALOG='
<window title="compton-settings" resizable="true" icon-name="preferences-desktop-display" allow-shrink="false">
<vbox>
	<menubar>
		<menu>
			<menuitem stock="gtk-save">
				<label>"'$" Save "'"</label>
				<action type="exit">save</action>
			</menuitem>
			<menuitem stock="gtk-close">
				<label>"'$" Exit "'"</label>
				<action type="exit">cancel</action>
			</menuitem>
			<label>'$"File"'</label>
		</menu>
		
		<menu>
			<menuitem label="'$"Start"'">
				<variable>DISPLAY_START</variable>
				<action>compton_start &</action>
				<action function="enable">DISPLAY_STOP</action>
				<action function="disable">DISPLAY_START</action>
				<visible>'$XSTART'</visible>
			</menuitem>	
			<menuitem label="'$"Stop"'">
				<variable>DISPLAY_STOP</variable>
				<action>killall compton &</action>
				<action function="disable">DISPLAY_STOP</action>
				<action function="enable">DISPLAY_START</action>
				<visible>'$XSTOP'</visible>
			</menuitem>
			<menuitem label="'$"Autostart On"'">
				<variable>DISPLAY_ASTART</variable>
				<action>cp /usr/share/applications/compton_start.desktop /'$HOME'/.config/autostart/  ; if [ -f /'$HOME'/.config/autostart/xcompmgr_start.desktop ]; then rm -rf /'$HOME'/.config/autostart/xcompmgr_start.desktop ; fi </action>
				<action function="enable">DISPLAY_ASTOP</action>
				<action function="disable">DISPLAY_ASTART</action>
				<visible>'$AUTOSTART'</visible>
			</menuitem>
			<menuitem label="'$"Autostart Off"'">
				<variable>DISPLAY_ASTOP</variable>
				<action>rm -rf /'$HOME'/.config/autostart/compton_start.desktop</action>
				<action function="disable">DISPLAY_ASTOP</action>
				<action function="enable">DISPLAY_ASTART</action>
				<visible>'$AUTOSTOP'</visible>
			</menuitem>
			<label>'$"Edit"'</label>
		</menu>
		<menu>
			<menu label="'$"Compton"'">
				<menuitem label="'$STATUS'"></menuitem>
			</menu>
			<menu label="'$"Autostart"'">
				<menuitem label="'$AUTO'"></menuitem>
			</menu>
			<menu label="'$"Current settings"'">
				<menuitem label="'$INFO'"></menuitem>
			</menu>			
			<menuitemseparator></menuitemseparator>
			<menuitem stock="gtk-help" label="About">
				<label>'$"About"'</label>
				<action type="launch">ABOUT</action>
			</menuitem>
			<label>'$"Help"'</label>
		</menu>
	</menubar>			

	<hbox>
		<notebook labels="'$"Simple|Main|Advanced"'" resizable="true" allow-shrink="true" show-tabs="true" show-border="true" space-expand="true" space-fill="true" tab-pos="2" >
			<vbox>
				<frame '$" Single commands (can not be selected with different settings) "'>
					<checkbox>
						<label>"'$"1 Compton (-cC -i 0.6 -e 0.6)"'"</label>
						<default>'$ST01'</default>
						<variable>S01</variable>
					</checkbox>	
					<checkbox>
						<label>"'$"2 Compton (-cC -i 0.6 -e 0.6 -fF)"'"</label>
						<default>'$ST02'</default>
						<variable>S02</variable>
					</checkbox>				
					<checkbox>
						<label>"'$"3 Compton (-cC -fF -I 0.065 -O 0.065 -D 6 -m 0.8 -i 0.6 -e 0.6)"'"</label>
						<default>'$ST03'</default>
						<variable>S03</variable>
					</checkbox>
					<checkbox>
						<label>"'$"4 Compton (-cCGfF -o 0.38 -O 200 -I 200 -t 0.02 -l 0.02 -r 3.2 -D2 -m 0.88)"'"</label>
						<default>'$ST04'</default>
						<variable>S04</variable>
					</checkbox>	
				</frame>
				<frame '$"Separate Settings"'>
					<checkbox>
						<label>"'$"Add a command, with copy'n'paste (can not be selected with different settings)."'"</label>
						<default>'$ST30'</default>
						<variable>S30</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Entry:"'</label></text>
							<entry>
							<default>'$ST31'</default>
							<variable>S31</variable>
							</entry>
						</hbox>						
				</frame>
				<frame '$"History..."'> 
					<tree selectable="true">
						<height>10</height>
						<variable>FILES</variable>
						<input file>'$CONF_DIR'/history</input> 
					</tree>
				</frame>
			</vbox>
			
			<vbox>	
				<frame '$" Main function "'>	
					<hseparator></hseparator>
					<checkbox>
						<label>"'$"Daemonize process."'"</label>
						<default>'$ST0'</default>
						<variable>S0</variable>
					</checkbox>	
					<checkbox>
						<label>"'$"Enabled client-side shadows on windows."'"</label>
						<default>'$ST1'</default>
						<variable>S1</variable>
					</checkbox>
					<checkbox>
						<label>"'$"Avoid drawing shadows on dock/panel windows."'"</label>
						<default>'$ST2'</default>
						<variable>S2</variable>
					</checkbox>
					<checkbox>
						<label>"'$"Fade windows in/out when opening/closing."'"</label>
						<default>'$ST3'</default>
						<variable>S3</variable>
					</checkbox>		
					<checkbox>
						<label>"'$"Fade windows during opacity changes."'"</label>
						<default>'$ST4'</default>
						<variable>S4</variable>
					</checkbox>	
					<checkbox>
						<label>"'$"Don't draw shadows on DND windows."'"</label>
						<default>'$ST5'</default>
						<variable>S5</variable>
					</checkbox>	
					<checkbox>
						<label>"'$"Zero the part of the shadow's mask behind the window (experimental)."'"</label>
						<default>'$ST6'</default>
						<variable>S6</variable>
					</checkbox>	
					<checkbox>
						<label>"'$"Enable synchronous operation (for debugging)"'"</label>
						<default>'$ST7'</default>
						<variable>S7</variable>
					</checkbox>	
				</frame>	
				<frame '$"Transparent Settings "'>
					<checkbox>
						<label>"'$"The opacity for menus."'"</label>
						<default>'$ST24'</default>
						<variable>S24</variable>
					</checkbox>	
					<hbox>
						<text><label>'$"Opacity (default 1.0):"'</label></text>
						<entry>
							<default>'$ST25'</default>
							<variable>S25</variable>
						</entry>
					</hbox>	
					<checkbox>
						<label>"'$"Opacity of inactive windows."'"</label>
						<default>'$ST26'</default>
						<variable>S26</variable>
					</checkbox>	
					<hbox>
						<text><label>'$"Opacity (0.1 - 1.0):"'</label></text>
						<entry>
							<default>'$ST27'</default>
							<variable>S27</variable>
						</entry>
					</hbox>	
					<checkbox>
						<label>"'$"Opacity of window titlebars and borders."'"</label>
						<default>'$ST28'</default>
						<variable>S28</variable>
					</checkbox>	
					<hbox>
						<text><label>'$"Opacity (0.1 - 1.0):"'</label></text>
						<entry>
							<default>'$ST29'</default>
							<variable>S29</variable>
						</entry>
					</hbox>											
				</frame>
			</vbox>
			
			<vbox>
				<frame '$"Advanced Settings"'>
					<checkbox>
						<label>"'$"Specifies which display should be managed"'"</label>
						<default>'$ST8'</default>
						<variable>S8</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Display:"'</label></text>
							<entry>
							<default>'$ST9'</default>
							<variable>S9</variable>
							</entry>
						</hbox>
					<checkbox>
						<label>"'$"Specifies the blur radius for client-side shadows "'"</label>
						<default>'$ST10'</default>
						<variable>S10</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Radius (default 12):"'</label></text>
							<entry>
							<default>'$ST11'</default>
							<variable>S11</variable>
							</entry>
						</hbox>	
					<checkbox>
						<label>"'$"Specifies the translucency for client-side shadows "'"</label>
						<default>'$ST12'</default>
						<variable>S12</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Opacity (default .75):"'</label></text>
							<entry>
							<default>'$ST13'</default>
							<variable>S13</variable>
							</entry>
						</hbox>	
					<checkbox>
						<label>"'$"Specifies the left offset for client-side shadows "'"</label>
						<default>'$ST14'</default>
						<variable>S14</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Left-Offset (default -15):"'</label></text>
							<entry>
							<default>'$ST15'</default>
							<variable>S15</variable>
							</entry>
						</hbox>	
					<checkbox>
						<label>"'$"Specifies the top offset for clinet-side shadows "'"</label>
						<default>'$ST16'</default>
						<variable>S16</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Top-Offset (default -15):"'</label></text>
							<entry>
							<default>'$ST17'</default>
							<variable>S17</variable>
							</entry>
						</hbox>		
					<checkbox>
						<label>"'$"Specifies the opacity change between steps while fading in "'"</label>
						<default>'$ST18'</default>
						<variable>S18</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Fade-In-Step (default 0.028):"'</label></text>
							<entry>
							<default>'$ST19'</default>
							<variable>S19</variable>
							</entry>
						</hbox>			
					<checkbox>
						<label>"'$"Specifies the opacity change between steps while fading out "'"</label>
						<default>'$ST20'</default>
						<variable>S20</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Fade-Out-Step (default 0.03):"'</label></text>
							<entry>
							<default>'$ST21'</default>
							<variable>S21</variable>
							</entry>
						</hbox>	
					<checkbox>
						<label>"'$"Specifies the time between steps in a fade in milliseconds "'"</label>
						<default>'$ST22'</default>
						<variable>S22</variable>
					</checkbox>	
						<hbox>
							<text><label>'$"Fade-Delta-Time (default 10):"'</label></text>
							<entry>
							<default>'$ST23'</default>
							<variable>S23</variable>
							</entry>
						</hbox>				
				</frame>
			</vbox>
		</notebook>	
	</hbox>
	</vbox>
</window>
'
}
#	Eval gtkdialog stdout into bash variables

I=$IFS; IFS=""
for STATEMENT in  $(gtkdialog --center --program=MAIN_DIALOG); do
	eval $STATEMENT
done
IFS=$I
	
{	
		# Process variables if dialog exit status == save
	if [ "$EXIT" == "save" ];then
		echo "$S01" > $CONF_DIR/s01
		echo "$S02" > $CONF_DIR/s02
		echo "$S03" > $CONF_DIR/s03
		echo "$S04" > $CONF_DIR/s04
		echo "$S0" > $CONF_DIR/s0
		echo "$S1" > $CONF_DIR/s1
		echo "$S2" > $CONF_DIR/s2
		echo "$S3" > $CONF_DIR/s3
		echo "$S4" > $CONF_DIR/s4
		echo "$S5" > $CONF_DIR/s5
		echo "$S6" > $CONF_DIR/s6
		echo "$S7" > $CONF_DIR/s7
		echo "$S8" > $CONF_DIR/s8
		if [ "$S9" == "?" ]; then
		echo nothing changed on setting 9
		else
		echo "$S9" > $CONF_DIR/s9
		fi
		echo "$S10" > $CONF_DIR/s10
		if [ "$S11" == "?" ]; then
		echo nothing changed on setting 11
		else
		echo "$S11" > $CONF_DIR/s11
		fi
		echo "$S12" > $CONF_DIR/s12
		if [ "$S13" == "?" ]; then
		echo nothing changed on setting 13
		else
		echo "$S13" > $CONF_DIR/s13
		fi
		echo "$S14" > $CONF_DIR/s14
		if [ "$S15" == "?" ]; then
		echo nothing changed on setting 15
		else
		echo "$S15" > $CONF_DIR/s15
		fi
		echo "$S16" > $CONF_DIR/s16
		if [ "$S17" == "?" ]; then
		echo nothing changed on setting 17
		else
		echo "$S17" > $CONF_DIR/s17
		fi
		echo "$S18" > $CONF_DIR/s18
		if [ "$S19" == "?" ]; then
		echo nothing changed on setting 19
		else
		echo "$S19" > $CONF_DIR/s19
		fi
		echo "$S20" > $CONF_DIR/s20
		if [ "$S21" == "?" ]; then
		echo nothing changed on setting 21
		else
		echo "$S21" > $CONF_DIR/s21
		fi
		echo "$S22" > $CONF_DIR/s22
		if [ "$S23" == "?" ]; then
		echo nothing changed on setting 23
		else
		echo "$S23" > $CONF_DIR/s23
		fi
		echo "$S24" > $CONF_DIR/s24
		if [ "$S25" == "?" ]; then
		echo nothing changed on setting 25
		else
		echo "$S25" > $CONF_DIR/s25
		fi
		echo "$S26" > $CONF_DIR/s26
		if [ "$S27" == "?" ]; then
		echo nothing changed on setting 27
		else
		echo "$S27" > $CONF_DIR/s27
		fi
		echo "$S28" > $CONF_DIR/s28
		if [ "$S29" == "?" ]; then
		echo nothing changed on setting 29
		else
		echo "$S29" > $CONF_DIR/s29
		fi
		if [ "$S31" == "?" ]; then
		echo nothing changed on setting 31
		else
		echo "$S31" > $CONF_DIR/s31
		fi
		
	else	#do nothing
		echo $"No settings were changed. Current configuration is maintained..."
		exit 0
	fi
}	
	killall compton
	read_settings
#------------------- INFO DIALOG ---------------------------------------
export INFO_DIALOG='
<window window_position="1" title="'$TITLE$VERSION'" icon-name="xcomp">
	<vbox>
		<hbox border-width="30">
			<pixmap>
				<input file icon="gtk-dialog-info"></input>
			</pixmap>
			<text use-markup="True">
				<label>"'$"New settings will be used... "'"</label>
			</text>
		</hbox>
		<hseparator></hseparator>
		<hbox homogeneous="true">
			<button ok></button>
		</hbox>
	</vbox>
</window>
'
gtkdialog --program=INFO_DIALOG 
	exec compton_start
