Friday, May 28, 2010

Make your own Usplash

#sudo apt-get install -y --force-yes libusplash-dev
#cd ~/.gnome2/nautilus-scripts/
#wget http://ubuntusoftware.info/scripts/MakeUsplash
#sudo chmod +x MakeUsplash

#!/bin/sh
# USplash Maker Via TheeMahn
# Copyright (c) 2007 Ubuntusoftware Team
#
# 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 2
# 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; withConversionout 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
SCRIPT_VERSION=1.00
FNAME="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
file=$@
# everything after last '/'
basename=${file%.*}
ext=".so"
OUTFILE=${basename}${ext}
`zenity --window-icon=/usr/share/ultimate/ubuntu_ico.png --info --text="This will complie a USplash in current folder called $OUTFILE you can then load this file into Startup Manager. Enjoy, TheeMahn" --title="USplash Maker"`;
##Check for zenity
if [ ! -e "/usr/bin/zenity" ]; then
gksudo apt-get install -y --force-yes zenity
fi

update() {
wget -O /tmp/MakeUsplash http://ubuntusoftware.info/scripts/MakeUsplash >/dev/null 2>&1
&sid=6bbd8592a0306af689e15ccceea67fb4
#Verify it did download it
RESULTS_SIZE=`stat -c %s /tmp/MakeUsplash`
if [ "$RESULTS_SIZE" = 0 ]
then
zenity --window-icon=/usr/share/ultimate/ubuntu_ico.png --info --text='It is suggested to re-run the script, the server may be under a heavy load. If the message persists, please verify you have an internet connection, the server is online & try again. Please refer to UbuntuSoftware Forum for further info.' --title="UbuntuSoftware USplashMaker";
exit 0
fi
#Version check script
REMOTE_VERSION=`grep SCRIPT_VERSION /tmp/MakeUsplash |head -n1 |sed 's/.*=//'`
if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
if [[ -n $DIALOG ]]
then
dialog --yesno "Newer version of USplash Maker script has been found\n\nDo you wish to install it?" 0 0
DIALOG_EXIT_CODE=$?
if [[ $DIALOG_EXIT_CODE = 0 ]]
then
cp /tmp/MakeUsplash ~/.gnome2/nautilus-scripts
echo "USplash Maker script has been updated to v $REMOTE_VERSION"
echo "Please re-run the script"
zenity --window-icon=/usr/share/ultimate/ubuntu_ico.png --info --text='Newer version of script detected '$REMOTE_VERSION'. It has been upgraded please re-run script.' --title="USplash Maker script";
exit
fi
else
cp /tmp/MakeUsplash /.gnome2/nautilus-scripts
echo "Newer version detected: $REMOTE_VERSION"
zenity --window-icon=/usr/share/ultimate/ubuntu_ico.png --info --text='Newer version of script detected '$REMOTE_VERSION'. It has been upgraded please re-run script.' --title="USplash Maker script";
exit
fi
fi
rm /tmp/MakeUsplash 2>/dev/null
}
update
PROGRESS=0
#FNAME=$@

#Resolution Subroutines
Res1(){
#cd $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
convert -colors 256 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -resize "640X400!" -quality 100 -strip WorkInProgress/usplash_640_400.png | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Processing @ 640 X 400..."
}

Res2(){
#cd $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
convert -colors 256 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -resize "640X480!" -quality 100 -strip WorkInProgress/usplash_640_480.png | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Processing @ 640 X 480..."
}

Res3(){
#cd $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
convert -colors 256 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -resize "800X600!" -quality 100 -strip WorkInProgress/usplash_800_600.png | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Processing @ 800 X 600..."
}

Res4(){
convert -colors 256 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -resize "1024X768!" -quality 100 -strip WorkInProgress/usplash_1024_768.png | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Processing @ 1024 X 768..."
}

Res5(){
#cd $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
convert -colors 256 $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS -resize "1280X1024!" -quality 100 -strip WorkInProgress/usplash_1280_1024.png | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Processing @ 1280 X 1024..."
}

#C Code Subroutines
Header(){
#Grab Throbbers, fonts & C code
cd WorkInProgress
wget http://ubuntusoftware.info/scripts/USplash/USplash.tar.gz
tar xfv USplash.tar.gz
cd ..
}

# Dialog box to choose USplash's size(s)
#SIZE="";
#SIZE="$(zenity --window-icon=/usr/share/ultimate/ubuntu_ico.png --width=500 --height=280 --title "Ubuntu Softwares Usplash Maker" --text "Choose the Usplash resolutions to be compiled." --list --checklist --column "Select" --column "Resolution" true '600X400' true '640X480' true '800X600' true '1024X768' true '1280X1024')";
#echo $SIZE
#if [ "${SIZE}" == "" ]; then
#zenity --error --text="Resolution not defined by user. Please choose a size to use. "
#exit 0
#fi
#n=0
#if echo "$SIZE" | grep "600X400" ; then
#n=$(($n + 1))
#echo -n "$n "
# fi
#if echo "$SIZE" | grep "640X480" ; then
#n=$(($n + 1))
#echo -n "$n "
# fi
#if echo "$SIZE" | grep "800X600" ; then
#n=$(($n + 1))
#echo -n "$n "
# fi
#if echo "$SIZE" | grep "1024X768" ; then
#n=$(($n + 1))
#echo -n "$n "
# fi
#if echo "$SIZE" | grep "1280X1024" ; then
#n=$(($n + 1))
#echo -n "$n "
# fi
# How many files to make the progress bar
#PROGRESS=0
#TOTAL=$((100 / $n))
#echo $TOTAL
mkdir -p WorkInProgress
Header
Res1
Res2
Res3
Res4
Res5
cd WorkInProgress
make | zenity --width=600 --height=100 --progress --pulsate --auto-close --title "Compiling USplash"

mv usplash-theme-ubuntu.so ../$OUTFILE
cd ..
#Clean up
rm -R WorkInProgress
exit 0