#!/bin/bash
#GUI by uelsk8s

vdir=/sbin #$(dirname $0)
. $vdir/vasm-functions
check_root
themes=$(ls /etc/bootsplash/themes|grep -v current)
i=0
for t in $themes;do
echo $t
 if [ $i = 0 ];then
   THEMES="$THEMES TRUE $t"
 else
   THEMES="$THEMES FALSE $t"
 fi 
   ((i++))
done
THEME=""
while [ "$THEME" = "" ];do
THEME1=$(zenity --list --title "BootSplash THEME" --radiolist --column choice \
 --column theme --text "Choose a Bootsplash theme." $THEMES)
if [ "$?" = 1 ];then
 exit 0
fi
#zenity --notification --text "use the $THEME1 theme?" --window-icon=/etc/bootsplash/themes/$THEME1/images/silent-800x600.jpg
DIALOG="Xdialog" 
TITLE="VLocity-Linux"
PIC="/etc/bootsplash/themes/$THEME1/images/silent-800x600.jpg"
convert $PIC -resize 30% /tmp/icon.xpm
ICON="/tmp/icon.xpm"
$DIALOG --icon $ICON --title $TITLE --yesno "Would you like to use \n the $THEME1 theme?" 400x260
if [ "$?" = 0 ];then
  THEME=$THEME1
fi
done
 ## Change the theme and remake the initrd    
if [ ! "$THEME" = "" ];then
  rm /etc/bootsplash/themes/current
  ln -s /etc/bootsplash/themes/$THEME /etc/bootsplash/themes/current
  /sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1024x768.cfg > /boot/initrd
  /sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-800x600.cfg >> /boot/initrd
  /sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1280x1024.cfg >> /boot/initrd
  zenity --question --title "Run LILO?" --text "Would you like to run lilo to update the initrd?"
  if [ "$?" == "0" ];then
   /sbin/lilo
  fi
fi
