#! /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

## -

ESCRITORIO=`cat ~/.config/lxsession/profile`

case $LANG in
  ca*)
    TIT="Estil d'escriptori"
    MSG1=" Actualment està emprant l'estil: \n \t\t<b>$ESCRITORIO</b> \n\n Desitja canviar-lo?"
    MSG2=" Perquè el canvi sigui efectiu ha de reiniciar la sessió. \n\n <b>Desitja reiniciar ara?</b>"
    MSG3=" Canviat l'estil d'escriptori. \n\n Recordeu, aquest canvi tindrà efecte \n en el proper inici. "
    PDI="PDI"
    ;;
  es*)
    TIT="Estilo de escritorio"
    MSG1=" Actualmente está empleando el estilo: \n \t\t<b>$ESCRITORIO</b> \n\n ¿Desea cambiarlo?"
    MSG2=" Para que el cambio sea efectivo debe reiniciar la sesión. \n\n <b>¿Desea reiniciarla ahora?</b>"
    MSG3=" Cambiado el estilo de escritorio. \n\n Recuerde, este cambio tendra efecto \n en el próximo inicio. "
    PDI="PDI"
  ;;
  gl*)
    TIT="Estilo de escritorio"
    MSG1=" Actualmente está a empregar o estilo: \n \t\t<b>$ESCRITORIO</b> \n\n Quere cambialo?"
    MSG2=" Para que o cambio teña efecto debe reiniciar a sesión. \n\n <b>Desexa reiniciar agora?</b>"
    MSG3=" Cambiado o estilo de escritorio. \n\n Lembre, este cambio tera efecto \n no próximo inicio. "
    PDI="EDI"
  ;;
  *)
    TIT="Desktop style"
    MSG1=" Currently you are using this style: \n \t\t<b>$ESCRITORIO</b> \n\n Would you like to change it?"
    MSG2=" Restore the session if you want the changes to have effect. \n\n <b>Would you like to restart now?</b>"
    MSG3=" Desktop Style was changed. \n\n Remember, this effect will be visible \n in the next restart. "
    PDI="IWB"
  ;;
esac

MessageChange(){
yad --window-icon="desktop" --image="desktop" \
    --button gtk-ok:0 --button gtk-no:1 --title "$TIT" --text "$MSG2"
	if [ "$?" == "0" ]; then
		pkill -SIGTERM lxsession
	else
		yad --window-icon="desktop" --image="desktop" \
			--button gtk-ok:0 --title "$TIT" --text "$MSG3"
	fi
}

MODE=$(yad --window-icon "desktop" \
    --title "$TIT" --text "$MSG1" \
    --list --print-column 1 --no-headers \
    --image "desktop" --width 300 --height 230 \
    --column "control" --column "acción":tip --hide-column 1 \
    L "MiniNo" \
    G "Gnome2 light" \
    P "PicarOS" \
    N "Netbook"\
    S "Mate"\
    A "Air"\
	T "Tablet"\
    Z "$PDI" )

if [ "$ret" == "1" ];then exit 0;fi

case $MODE in
	'L|')
		echo "LXDE" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'G|')
		echo "GNOME2" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'P|')
		echo "PICAROS" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'N|')
		echo "NETBOOK" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'A|')
		echo "AIR" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'S|')
		echo "MATE" > ~/.config/lxsession/profile
		MessageChange
    ;;
	'T|')
		echo "TABLET" > ~/.config/lxsession/profile
		MessageChange
    ;;


	'Z|')
		echo "PDI" > ~/.config/lxsession/profile
		MessageChange
    ;;
esac

