#! /bin/bash

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

case $ESCRITORIO in
  LXDE*) ALTER1="GNOME2" ALTER2="KDE3" ALTER3="UNITY";;
  GNOME2*) ALTER1="LXDE" ALTER2="KDE3" ALTER3="UNITY";;
  KDE3*) ALTER1="LXDE" ALTER2="GNOME2" ALTER3="UNITY";;
  UNITY*) ALTER1="LXDE" ALTER2="GNOME2" ALTER3="KDE";;

  *) exit 1 ;;	
esac

case $LANG in
  es*)
    TIT="Estilo de escritorio"
    MSG1=" Actualmente está empleando el estilo: \n \t\t<b>$ESCRITORIO</b> \n Puede cambiarlo por el estilo: "
    MSG2=" Para que el cambio sea efectivo debe reiniciar la sesión. \n\n <b>¿Desea reiniciar ahora?</b>"
    MSG3=" Cambiado el estilo de escritorio. \n\n Recuerde, este cambio tendra efecto \n en el próximo inicio. "
  ;;
  gl*)
    TIT="Estilo"
    MSG1=" Actualmente está empregando o estilo: \n \t\t<b>$ESCRITORIO</b> \n\n Pode cambialo polo estilo: "
    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. "
  ;;
  pt_BR)
    TIT="Estilo de escritorio"
    MSG1=" Actualmente está empleando el estilo: \n \t\t<b>$ESCRITORIO</b> \n Puede cambiarlo por el estilo: "
    MSG2=" Para que el cambio sea efectivo debe reiniciar la sesión. \n\n <b>¿Desea reiniciar ahora?</b>"
    MSG3=" Cambiado el estilo de escritorio. \n\n Recuerde, este cambio tendra efecto \n en el próximo inicio. "
  ;;
  *)
    TIT="Estilo de escritorio"
    MSG1=" Currently you are using this style: \n \t\t<b>$ESCRITORIO</b> \n You can change for: "
    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. "
  ;;
esac

ALTER=$(yad --window-icon=applications-development --width 300 \
    --entry --title "$TIT" --image=desktop \
    --button="gtk-ok:0" --button="gtk-no:1" \
    --text "$MSG1" \
    --entry-text \
    "$ALTER1" "$ALTER2" "$ALTER3")
ret=$?
[[ $ret -eq 1 ]] && exit 0


rpl $ESCRITORIO $ALTER .config/lxsession/profile

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