--- trunk/busybox/splash-functions.rc 2011/01/28 19:39:02 1273 +++ trunk/busybox/splash-functions.rc 2012/07/13 09:54:26 1838 @@ -5,9 +5,63 @@ splash() { + local cmd + local args + + # check for a framebuffer console first! + [[ ! -e /dev/fb0 ]] && return 0 + # proc must be mounted too + [[ ! -e /proc/cmdline ]] && return 0 + # only run fbsplash if theme was found + [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME} ]] && return + # and run only if a config for the current resolution exist + [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME}/$(splash_resolution).conf ]] && return + + # create fifo if not exist + if [[ ! -w ${SPLASH_FIFO} ]] + then + mkfifo ${SPLASH_FIFO} + fi + + # check cmdline for config_opts + # splash=silent,theme:mcore + for cmd in $(< /proc/cmdline) + do + case "${cmd}" in + splash=*) + # split the cmd and put everything into an array + args=( $(echo "${cmd}" | sed 's:[,\:=]:\ :g') ) + # mode is always args[1] + SPLASH_MODE="${args[1]}" + # theme is always args[3] + SPLASH_THEME="${args[3]}" + ;; + esac + done + case $1 in rc_init) rc_init ;; rc_verbose|rc_exit) rc_exit ;; + # redraw splash image and text + svc_started) + if [[ ${runlevel} = boot ]] || [[ ${runlevel} = sysinit ]] + then + splash_control "image:" + splash_control "write:${SPLASH_BOOT_MESSAGE}" + fi + ;; + svc_stopped) + if [[ ${runlevel} = shutdown ]] + then + splash_control "image:" + splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}" + fi + if [[ ${runlevel} = reboot ]] + then + splash_control "image:" + splash_control "write:${SPLASH_REBOOT_MESSAGE}" + fi + ;; esac } @@ -17,10 +71,10 @@ then local resolution="$(splash_resolution)" - splash_cursor disable chvt ${SPLASH_TTY} + sleep 0.5 - if [[ $runlevel = boot ]] || [[ ${runlevel} = sysinit ]] + if [[ ${runlevel} = boot ]] || [[ ${runlevel} = sysinit ]] then fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \ -s ${SPLASH_THEMES}/${SPLASH_THEME}/startup-${resolution}.ppm.gz \ @@ -28,6 +82,7 @@ -f ${SPLASH_FIFO} \ ${SPLASH_OPTS} & + wait_for_fbsplash splash_control "write:${SPLASH_BOOT_MESSAGE}" fi @@ -39,10 +94,11 @@ -f ${SPLASH_FIFO} \ ${SPLASH_OPTS} & + wait_for_fbsplash splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}" fi - if [[ $runlevel = reboot ]] + if [[ ${runlevel} = reboot ]] then fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \ -s ${SPLASH_THEMES}/${SPLASH_THEME}/reboot-${resolution}.ppm.gz \ @@ -50,6 +106,7 @@ -f ${SPLASH_FIFO} \ ${SPLASH_OPTS} & + wait_for_fbsplash splash_control "write:${SPLASH_REBOOT_MESSAGE}" fi fi @@ -60,8 +117,12 @@ if [[ ${SPLASH_MODE} = silent ]] then splash_control "exit" - splash_cursor enable - chvt 1 + if [[ -n ${SPLASH_X11_TTY} ]] + then + chvt ${SPLASH_X11_TTY} + else + chvt 1 + fi fi } @@ -70,6 +131,14 @@ fbres } +wait_for_fbsplash() +{ + while [[ -z $(pidof fbsplash) ]] + do + sleep 0.1 + done +} + splash_control() { # only write to fifo if the fbsplash process is runnning @@ -79,12 +148,3 @@ echo "$@" > ${SPLASH_FIFO} fi } - -# disable|enable -splash_cursor() -{ - case $1 in - enable) echo -e "\e[?0c";; - disable) echo -e "\e[?1c" ;; - esac -}