Yesterday I saw a post about changing the grub and bootsplash images and I rememberd that some time ago I had the intention of making a script to test different images.
Gathering ideas from Joble, Sproggy and all the great people around here, I wrote the following script.
It's ugly, I have no idea of why it does what it does, but it works quite well (At least, I tested it with several images both in mys system and in a vbox install and it worked).
It gives you the option to change both images or restore the ones you backed up.
It has three main problems:
1) If you cancel in the middle of the script, I don't know what the hell happens.
2) It only works if you have the minime default theme enabled for both images. (Which obviously means that it won't work outside PCLinuxOS)
3) It was written by someone who doesn't have a clue as to what all those strange symbols in the script mean.
If anyone could throw in some ideas, corrections, etc., it could become a little better.
EDIT: 2nd version:
EDIT2: 3rd version (this morning I came across the way to make the cancel button in the dialogs actually cancel)
#!/bin/bash -x
if [ "$UID" != "0" ]; then
zenity --error --text="Please run this script as root!"
exit 0
fi
if [ ! -e /usr/bin/convert ]; then
zenity --error --text "Imagemagick could not be found in your system. Please, install it and run this script again."
exit 0
fi
if [ ! -e /usr/bin/mogrify ]; then
zenity --error --text "Imagemagick could not be found in your system. Please, install it and run this script again."
exit 0
fi
if [ -d ~/tmp/grubbish ]; then
rm -R ~/tmp/grubbish
fi
#################################### Functions
function Dial
{
OPTION=`zenity --width=330 --height=300 --text "Please select an option" --list --radiolist --column " " --column "Options" True "1. Change the Grub Image" False "2. Change the Bootsplash Image" False "3. Restore the Grub image" False "4. Restore the Bootsplash image" False "5. Restore both images" False "6. Exit"`
}
function Alt1
{
mkdir ~/tmp/grubbish
mkdir ~/tmp/grubbish/GRUB
cd ~/tmp/grubbish/GRUB
echo "Trying to backup default Grub image"
if [ -f /usr/share/gfxboot/themes/minime09/boot/message_BACKUP ]; then
echo "Backup already exists"
else cp /usr/share/gfxboot/themes/minime09/boot/message /usr/share/gfxboot/themes/minime09/boot/message_BACKUP
fi
cp /usr/share/gfxboot/themes/minime09/boot/message .
cpio -i < message
rm -f message
rm -f back.jpg
InGRUB=`zenity --file-selection --filename /home/ --title="Select a file for the Grub image"`
if [ $? = 1 ]; then echo "Script cancelled by the user"; rm -R ~/tmp/grubbish; exit; fi
cp "$InGRUB" ~/tmp/grubbish/GRUB/back.jpg
mogrify -strip back.jpg
convert back.jpg -colors 24 back.jpg
convert back.jpg -resize 800x600\! back.jpg
ls . | cpio -o > message
cp -f message /usr/share/gfxboot/themes/minime09/boot/
/usr/sbin/grub-gfxmenu --update-gfxmenu
zenity --info --text "Done"
cd
rm -R ~/tmp/grubbish
}
function Alt2
{
mkdir ~/tmp/grubbish/
mkdir ~/tmp/grubbish/BOOT
mkdir ~/tmp/grubbish/BOOT/OUT
echo "Trying to backup default Bootsplash images"
if [ -d /usr/share/bootsplash/themes/minime09_BACKUP ]; then
echo "Backup already exists"
else cp -R /usr/share/bootsplash/themes/minime09 /usr/share/bootsplash/themes/minime09_BACKUP
fi
InBOOT=`zenity --file-selection --filename /home/ --title="Select a file for the Bootsplash image"`
if [ $? = 1 ]; then echo "Script cancelled by the user"; rm -R ~/tmp/grubbish; exit; fi
cp "$InBOOT" ~/tmp/grubbish/BOOT/base
cd ~/tmp/grubbish/BOOT
mogrify -strip base
convert base -resize 50% base
convert base -resize 1024x768\! OUT/bootsplash-1024x768.jpg
convert base -resize 1280x1024\! OUT/bootsplash-1280x1024.jpg
convert base -resize 1600x1200\! OUT/bootsplash-1600x1200.jpg
convert base -resize 640x480\! OUT/bootsplash-640x480.jpg
convert base -resize 800x600\! OUT/bootsplash-800x600.jpg
cd OUT
cp -f * /usr/share/bootsplash/themes/minime09/images
BootResolution=`zenity --width=320 --height=310 --text "Please select the Bootsplash resolution" --list --radiolist --column " " --column "Resolution" False "640x480" False "800x600" True "1024x768" False "1280x1024" False "1600x1200"`
make-boot-splash /boot/initrd.img $BootResolution
cd
zenity --info --text "Done"
rm -R ~/tmp/grubbish
}
function Alt3
{
if [ -e /usr/share/gfxboot/themes/minime09/boot/message_BACKUP ]; then
rm -f /usr/share/gfxboot/themes/minime09/boot/message
mv /usr/share/gfxboot/themes/minime09/boot/message_BACKUP /usr/share/gfxboot/themes/minime09/boot/message
zenity --info --text "Your Grub image has been restored"
else zenity --error --text "No backup file was found."
rm -R ~/tmp/grubbish
fi
}
function Alt4
{
if [ -e /usr/share/bootsplash/themes/minime09_BACKUP ]; then
rm -fR /usr/share/bootsplash/themes/minime09
mv /usr/share/bootsplash/themes/minime09_BACKUP /usr/share/bootsplash/themes/minime09
zenity --info --text "Your Bootsplash image has been restored"
else zenity --error --text "No backup file was found"
fi
}
######################################
Dial
if [[ $OPTION = "1. Change the Grub Image" ]]; then
Alt1
Dial
elif [[ $OPTION = "2. Change the Bootsplash Image" ]]; then
Alt2
Dial
elif [[ $OPTION = "3. Restore the Grub image" ]]; then
Alt3
Dial
elif [[ $OPTION = "4. Restore the Bootsplash image" ]]; then
Alt4
Dial
elif [[ $OPTION = "5. Restore both images" ]]; then
Alt3
Alt4
Dial
elif [[ $OPTION = "6. Exit" ]]; then
exit 0
fi
[attachment deleted by admin]