# change the grub splash.xpm.gz link
# 2006/3/30 11:32
# author : zhi-hau(zigo)
# say: if system second == filename , change ln -s
# script name: chsplash.sh
######
# declare variable.
IMGDIR=/boot/grub/images/
IMGNUM=`ls $IMGDIR|nl|tail -1|awk '{print $1}'`
CURSEC=`date +"%S"`
RAN=`expr $CURSEC % $IMGNUM`
FILLIST=`ls $IMGDIR`
SPLASH=/boot/grub/splash.xpm.gz
# remove splash.xpm.gz link
# && -L $splashLnk
if [ -e "$SPLASH" ] && [ -L "$SPLASH" ]; then
rm -f $SPLASH
echo "rm: '$SPLASH'";
else
echo "$0: Error: '$SPLASH' is not found." ; exit 1
fi
# link image.xpm.gz file function
function fSecmp()
{
for filename in $FILLIST
do
filt=`echo $filename |sed 's/.xpm.gz//'`
if [ $1 -eq $filt ]; then
ln -s $IMGDIR$filename $SPLASH
echo "ln: -s $IMGDIR$filename $SPLASH.";
fi
done
}
CURSEC=`echo $CURSEC|sed 's/^0//'`
if [ $CURSEC -lt $IMGNUM ]; then
fSecmp $CURSEC
else
fSecmp $RAN
fi
echo "Changed splash image!"
####script end
使用前須做:
cd /boot/grub; mv splash.xpm.gz splash.xpm.gz.old;
mkdir images; #將filename.xpm.gz放到images目錄, 並更名為0.xpm.gz, 1.xpm.gz , ...
ln -s images/0.xpm.gz splash.xpm.gz #建立一個連結
vim /etc/rc.d/rc.local ;
#編輯檔案加入所在目錄/chsplash.sh
問題:
每次啟動系統候就會更換link, 可是會有剛好同秒的情況發生, 也就是下次啟動還是同個開機選單背景.