QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 4629|回复: 24

在pre6下制作动画启动界面

[复制链接]
发表于 2004-5-5 11:41:51 | 显示全部楼层 |阅读模式
在ml1.6启动时显示滚动条
如图

本文参考linuxsir的《轻松拿下Bootsplash》作者tram

1.下载支持动画的主题  
       到www.bootsplash.org下载,我选择了redmond主题
       ftp://ftp.suse.com/pub/people/stepan/bootsplash/themes/Theme-Redmond.tar.bz2
2.将主题解到/etc/bootsplash/themes下,删除current连接,建立新连接
        cp Theme-Redmond.tar.bz2 /etc/bootsplash/themes
        tar -xjvf Theme-Redmond.tar.bz2
        rm current
        ln -s Redmond current
3.修改主题图片/etc/bootsplash/themes/current/images/silent-1024x768.jpg
        我是采用了magic专栏的图片

4.重写intrd
        /sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1024x768.cfg >> /boot/initrd-1024x768        
   修改grub 把intrd改成如上的

5.写两个脚本存放在/sbin中
bootanim.sh:

源码:

#!/bin/bash
#
# splash.sh - This shell script triggers bootsplash actions during
# system boot/shutdown. It can be run by the init scripts repeatedly
# specifying the currently executed system script.
#
# This script is used to play animations/sounds/show text/move the
# progress bar, etc.
#
# We call this function from /etc/rc.status:rc_splash()
#
# This program is free software; you may redistribute it under
# the terms of the GNU General Public License. This program has
# absolutely no warranty.
#
# written 2002-2003 Stefan Reinauer, <[email protected]>
#
# this script expects the following environment variables for an
# operable
# progress bar:
#
#  sscripts = number of start scripts to be executed for runlevel change
#  kscripts = number of stop scripts to be executed for runlevel change
#  progress = number of currently executed start/stop script
#  RUNLEVEL = runlevel to be reached.
#
# To play animations, it's advised that you have an animations.cfg in
# your
# theme's config directory specifying the initscript name for an event
# and
# the command to be executed:
#
#   fsck start:bootanim start bounce.mng
#   master:bootanim stop
#
# See http://www.bootsplash.org/ for more information.
#

_procsplash="`cat /proc/splash 2>/dev/null`"

THEME="current"
#test -f /etc/sysconfig/bootsplash && . /etc/sysconfig/bootsplash
test ! -d "/etc/bootsplash/themes/$THEME" && exit 0

# parse animations.cfg. This part should not be handled by the
# splash binary.

function box() { true; } # ignore box descriptions in the config file

test -f
"/etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg" &&
\
  . /etc/bootsplash/themes/$THEME/config/bootsplash-`fbresolution`.cfg

if [ -f /etc/bootsplash/themes/$THEME/config/animations.cfg ]; then
  COMMAND="`cat /etc/bootsplash/themes/$THEME/config/animations.cfg |
grep "^$1"|cut -f2 -d\:`"
  eval $COMMAND
fi


第二个是bootanim:

源码:

#!/bin/bash
#
# bootanim - boot animation wrapper script for fbmngplay
#
# This script parses /usr/share/splash/current/config/bootsplash-XxY.cfg
# to determine the correct animation position.
#
# (C) 2002 SuSE AG. Written by Stefan Reinauer <[email protected]>
#
# modified by Michael Aichler <micha at aichler dot net>
#
usage()
{
    echo "Usage: `basename $0` COMMAND [OPTIONS] mng1 [mng2 ...]"
    cat << EOF

  Available commands:
        start           starts given animation
        stop            fades out all running animations
        kill            immediately stops all animations
        next            kills current and starts next animation.

  Options for use with start command:
EOF
        echo -e "`fbmngplay -h 2>&1 | grep -v \"usage:\" | grep
\"-\"`\n"
}

if [ ! -x /sbin/splash ]; then
        echo "`basename $0`: can't find splash utility"
        exit 1
fi

DIRECTORY=/etc/bootsplash/themes/current/animations
OPTIONS=""
FILES=""
buffer=""
console=""

case "$1" in
        start)
                # We fall through here.
                ;;
        stop)
                killall -q -2 fbmngplay
                exit 0
                ;;
        kill)
                killall -q fbmngplay
                exit 0
                ;;
        next)
                killall -q -USR1 fbmngplay
                exit 0
                ;;
        *)
                echo "`basename $0`: illegal parameter."
                usage
                exit 1
                ;;
esac

shift

# We end up in bootanim start

for arg in $*; do
        if [ "${arg#*.}" == "mng" ]; then
                FILES="$FILES $arg"
        else
                test "$arg" == "-b" && buffer="true"
                test "$arg" == "-c" && console="true"
                OPTIONS="$OPTIONS $arg"
        fi
done

test -f
"/etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg" &&
\
  . /etc/bootsplash/themes/current/config/bootsplash-`fbresolution`.cfg


test -z "$buffer" && OPTIONS="$OPTIONS -b"
test -z "$console" && OPTIONS="$OPTIONS -c 1"
echo $ax
OPTIONS="$OPTIONS -x 420 -y 580"
CMDLINE="fbmngplay $OPTIONS"

for file in $FILES; do
        CMDLINE="$CMDLINE ${DIRECTORY}/${file}"
done

eval "$CMDLINE &"

修改属性
chmod 755 bootanim.sh bootanim

5.在/etc/rc.d/init.d/functions里增加新的函数。

源码:

animate()
{

        if [ $# = 0 ]
                then
                        echo "Usage: animate {hook}"
                        exit 1
                fi

        /sbin/bootanim.sh "$*"

}


6.修改/etc/rc.d/rc.sysinit,也就是加几行:
找到这里
  # Graphical bootup...
if [ "$BOOTUP" = "graphical" ]; then
   if [ -w /proc/splash -a -e /proc/fb ]; then
      # Initialize bootsplash
      # TODO: Find out runlevel (-> number of startup scripts -> number of steps)
      runlevel=5
      export kscripts=`/bin/ls /etc/rc.d/rc$runlevel.d/K* |/usr/bin/wc |/bin/awk '{ print $1 }'`
      export sscripts=`/bin/ls /etc/rc.d/rc$runlevel.d/S* |/usr/bin/wc |/bin/awk '{ print $1 }'`
      export progress=1
      # HACK: count rc.sysinit stuff as startup scripts...
      sscripts=$(( $sscripts + 19 ))
      animate fsck start  //这就是新加的行
   else
      # Kernel doesn't have bootsplash support --> switch to text
      export BOOTUP=color
   fi
fi

7.在/etc/rc.d/init.d/下修改几个脚本,用于结束动画,我是用了alaasound这一个的,大家可以找你们启动时最后运行的脚本
在start()最后加一行
  找到此处
  function start() {
  #
  # insert all sound modules
  #

  module_loaded=0
  drivers=`/sbin/modprobe -c | \
    grep -E "^[[:space:]]*alias[[:space:]]+snd-card-[[:digit:]]" | \
    awk '{print $3}'`
  for i in $drivers; do
    if [ "$i" != off ]; then
      echo -n "Starting sound driver: $i "
      probe_module $i && module_loaded=1
      echo -e "$rc_done"
    fi
  done
  test $module_loaded -eq 0 && return
  #
  # insert sequencer modules
  #
  if [ x"$START_ALSA_SEQ" = xyes -a -r /proc/asound/seq/drivers ]; then
    cut -d , -f 1 /proc/asound/seq/drivers | \
    while read t ; do
      test -z $t || /sbin/modprobe $t
    done
  fi
  #
  # restore driver settings
  #
  if [ -d /proc/asound ]; then
    if [ ! -r $asoundcfg ]; then
      echo "No mixer config in $asoundcfg, you have to unmute your card!"
    else
      if [ -x $alsactl ]; then
        $alsactl -F -f $asoundcfg restore
      else
        echo -e "${rc_warning}ERROR: alsactl not found${rc_reset}"
      fi
    fi
  fi
  #
  # run card-dependent scripts
  for i in $drivers; do
    t=${i##snd-}
    if [ -x $alsascrdir/$t ]; then
      $alsascrdir/$t
    fi
  done

  #
  # touch lockfile if lockdir exists
  #
  if [ -d /var/lock/subsys ] ; then
    touch /var/lock/subsys/alsasound
  fi
  animate master  //加入此行
}

再找到此处  
function stop() {
  #
  # store driver settings
  #
  if [ -x $alsactl ]; then
    $alsactl -f $asoundcfg store
  else
    echo -n -e "${rc_warning}!!!alsactl not found!!!${rc_reset} "
  fi
  #
  # mute master to avoid clicks at unload
  #
  /usr/bin/amixer set Master mute >/dev/null 2>&1
  #
  # remove all sound modules
  #
  $lsmod | grep -E "^snd" | grep -Ev "(snd-page-alloc|snd_page_alloc)" | while read line; do \
     /sbin/rmmod `echo $line | cut -d ' ' -f 1`; \
  done
  # remove the 2.2 soundcore module (if possible)
  /sbin/rmmod soundcore 2> /dev/null
  /sbin/rmmod gameport 2> /dev/null

  #
  # remove lockfile if lockdir exists
  #
  if [ -d /var/lock/subsys ] ; then
    rm -f /var/lock/subsys/alsasound
  fi
  animate shutdown  //加入此行
  
  到此为止,可以重启了。你应该可以看到了滚动条了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2004-5-5 13:06:54 | 显示全部楼层
先谢谢了先
回复

使用道具 举报

发表于 2004-5-5 13:25:41 | 显示全部楼层
4.重写intrd
/sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1024x768.cfg >> /boot/initrd-1024x768
修改grub 把intrd改成如上的(是不是把“splashimage=(hd0,10)/boot/grub/splash.xpm.gz”换成/sbin/splash -s -f /etc/bootsplash/themes/current/config/bootsplash-1024x768.cfg ?
“initrd /boot/initrd-2.6.4-1mgc.img”换成“/boot/initrd-1024x768 ”?)

修改属性
chmod 755 bootanim.sh bootanim  (直接在终端输入这一命令吗)

以上两步不是太清楚,能否详细一点?谢谢
回复

使用道具 举报

发表于 2004-5-5 15:32:28 | 显示全部楼层
我也来一帖,从www.bootsplash.org转过来的(http://www.bootsplash.org/themeinfo.html):

Themeing

It's possible to create different themes for the bootsplash screen. This makes it easier to exchange the pictures and animations shown during bootup. The current theme is selected by the THEME variable in /etc/sysconfig/bootsplash. If you change the theme on a SuSE machine first call "SuSEconfig --module bootsplash" to activate it. You also have to call "mkinitrd" and, if using lilo as bootloader, "lilo" afterwards. Bootsplash themes can be stored in /etc/bootsplash/themes.

Each theme has its own directory with several subdirectories:

images/
contains jpeg pictures for the current splash theme. It's suggested that each picture should have a text area of at least 80x25 so all boot messages can be seen properly. If you create a theme with the text window residing at a different position than the default one, you need to change this in the configuration files. See configuration files in config/. If you change a picture here, you need to call mkinitrd to notify the kernel about the new picture.

config/
contains config files for the different jpeg pictures (defining text area and such) as well as the bootup animation config file (animations.cfg) If you change the bootsplash picture configuration, you need to call mk_initrd to notify the kernel about your changes. This is not needed if you change the animation configuration in animation.cfg

animations/
contains the status animations that are shown during bootup. see config/ for configuration file. The animations are stored in the portable and free MNG format, the animated companion of the PNG file format. You can easily create animations from a PNG or JPG picture series using "convert" from the ImageMagick package.

Example: convert -delay 20 anim*.png anim.mng

bootloader/
"message" file for bootloader (i.e. lilo/grub). If you change this file you need to call "SuSEconfig --module bootsplash" and, possibly, "lilo" afterwards.

In version 3 almost everything is themeable, and yes, almost everything is defined in the configuration files. Because the format of the configuration files is somewhat obtuse you'll need to read the information in the Configuration Files section.
回复

使用道具 举报

发表于 2004-5-5 18:06:50 | 显示全部楼层
gooooooooooooood!
干得漂亮!
回复

使用道具 举报

 楼主| 发表于 2004-5-5 20:28:43 | 显示全部楼层
对不起,今天晚上重新想了一下,实现这个并不需要这么烦的,于是重新做了一下
如下:
      其实原理也就是利用fbmngplay这么程序,magic上有,
[root@MagicLinux huting]# fbmngplay -h

usage: fbmngplay [ -x <val> ] [ -y <val> ] [ -a <val> ] [-b] [-v] [-s] [file.mng [file.mng [...]]]

        -x: x coordinate
        -y: y coordinate
        -a, --alpha: default alpha channel 1..100
        -v, --verbose: verbose mode
        -b, --buffered: buffered mode
        -s, --signal: wait for SIGUSR1 between animations
        -p, --position: dynamically select position
        -V, --version: show version and exit
        -?, -h, --help: print this help.
        -S --start-console: only output animation on console it was started on.
       -c: start output animation on specified console.

也来写一个脚本:
animate.sh放在/sbin中
源码:
case "$1" in
        start)
                 fbmngplay -x 420 -y 580 /etc/bootsplash/themes/current/animations/bounce.mng &
                 exit 0
                 ;;
        stop)
                killall -q fbmngplay
                exit 0
                ;;
esac

将其的属性改为可执行。
chmod +x animate.sh

然后在/etc/rc.d/rc.sysinit中加入一行
找到这一段
# Graphical bootup...
if [ "$BOOTUP" = "graphical" ]; then
   if [ -w /proc/splash -a -e /proc/fb ]; then
      # Initialize bootsplash
      # TODO: Find out runlevel (-> number of startup scripts -> number of steps)
      runlevel=5
      export kscripts=`/bin/ls /etc/rc.d/rc$runlevel.d/K* |/usr/bin/wc |/bin/awk '{ print $1 }'`
      export sscripts=`/bin/ls /etc/rc.d/rc$runlevel.d/S* |/usr/bin/wc |/bin/awk '{ print $1 }'`
      export progress=1
      # HACK: count rc.sysinit stuff as startup scripts...
      sscripts=$(( $sscripts + 19 ))
      /sbin/animate.sh start  <-加入这一行,在启动时运行fbmngplay
   else
      # Kernel doesn't have bootsplash support --> switch to text
      export BOOTUP=color
   fi
fi

要关掉fbmngplay也行简单。我是找到/etc/rc.d/init.d有找到最后一个运行的脚来,在start)那一段最后加一句
/sbin/animate.sh stop
比如我最后运行的是vmware。所以,修改vmware
case "$1" in <-找到这一段
  start)
        if [ -e "$vmware_etc_dir"/not_configured ]; then
           echo "`vmware_product_name`"' is installed, but it has not been (correctly) configured'
           echo 'for the running kernel. To (re-)configure it, invoke the'
           echo
           ...
         
        [ -d /var/lock/subsys ] || mkdir -p /var/lock/subsys
        touch /var/lock/subsys/"$subsys"
        /sbin/animate.sh stop <-加入这一行
        ;;

关闭系统时,首先关闭的是atd,所以在atd的脚本中stop)段最开始加一句
/sbin/animate.sh start

stop() {
        /sbin/animate.sh start  <-加入这一行
        echo -n $"Stopping $prog: "
        killproc /usr/sbin/atd
        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/atd
        echo
        return $RETVAL
这样就行了:)
回复

使用道具 举报

发表于 2004-5-5 21:58:49 | 显示全部楼层
gooooooooooooooooooooood
回复

使用道具 举报

 楼主| 发表于 2004-5-6 09:29:57 | 显示全部楼层
大家反应不强列呀??
回复

使用道具 举报

发表于 2004-5-6 10:08:43 | 显示全部楼层
对于新手,还是有些复杂,我照前一方法试过,最后弄得半桶水(不但不成功,而且把默认的那个搞坏了--那个进度条不动了,十分不舒服),现在还心有余悸!
回复

使用道具 举报

发表于 2004-5-6 12:07:06 | 显示全部楼层
Good@!

更换成功!
回复

使用道具 举报

 楼主| 发表于 2004-5-6 13:50:20 | 显示全部楼层
呵,对不起呀,对于上一种方法,我也是对着人家的方法做的,不是很明白,因为ml的一些脚本与别的版本不一样,第二种方法应该比较简单了吧
回复

使用道具 举报

 楼主| 发表于 2004-5-6 20:41:00 | 显示全部楼层
我已经把主题放到公社下载了,不过脚本还理自已写了,我自已的水平也是很菜的了
回复

使用道具 举报

发表于 2004-5-7 00:28:54 | 显示全部楼层
麻烦啊,现在我很难的搞这些玩意儿了
回复

使用道具 举报

 楼主| 发表于 2004-5-7 08:54:13 | 显示全部楼层
我也只是前天看到公社的自由软件区有人在说这个问题,我就想在linux可不可实现与xp一样的效果,找了一些文章,与大家分享:)
回复

使用道具 举报

发表于 2004-6-9 15:15:21 | 显示全部楼层
用第二种方法成功
但是启动的时候 滚动条 要等一会出现 而且按f2 之后 滚动条还在
有什么解决的方法吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-10 21:50 , Processed in 0.119418 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表