Magellan Linux

Contents of /trunk/busybox/splash-functions.rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1279 - (show annotations) (download)
Sun Feb 6 22:32:23 2011 UTC (13 years, 2 months ago) by niro
File size: 2946 byte(s)
- only run splash themes on a framebuffer console
- only run splash themes if a config for the current reolution exists
- respect cmdlines in form of splash=mode,theme:name pragma (e.g. splash=silent,theme:mcore)

1 # /etc/rc.d/init.d/splash-functions - splashfunctions for busybox' fbsplash with tykef patch
2 # $Id$
3
4 [[ -f /etc/splash/splash.conf ]] && . /etc/splash/splash.conf
5
6 splash()
7 {
8 local cmd
9 local args
10
11 # check for a framebuffer console first!
12 [[ ! -e /dev/fb0 ]] && return 0
13 # proc must be mounted too
14 [[ ! -e /proc/cmdline ]] && return 0
15 # only run fbsplash if theme was found
16 [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME} ]] && return
17 # and run only if a config for the current resolution exist
18 [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME}/$(splash_resolution).conf ]] && return
19
20 # check cmdline for config_opts
21 # splash=silent,theme:mcore
22 for cmd in $(< /proc/cmdline)
23 do
24 case "${cmd}" in
25 splash=*)
26 # split the cmd and put everything into an array
27 args=( $(echo "${cmd}" | sed 's:[,\:=]:\ :g') )
28 # mode is always args[1]
29 SPLASH_MODE="${args[1]}"
30 # theme is always args[3]
31 SPLASH_THEME="${args[3]}"
32 ;;
33 esac
34 done
35
36 case $1 in
37 rc_init) rc_init ;;
38 rc_verbose|rc_exit) rc_exit ;;
39 esac
40 }
41
42 rc_init()
43 {
44 if [[ ${SPLASH_MODE} = silent ]]
45 then
46 local resolution="$(splash_resolution)"
47
48 splash_cursor disable
49 chvt ${SPLASH_TTY}
50 sleep 0.5
51
52 if [[ $runlevel = boot ]] || [[ ${runlevel} = sysinit ]]
53 then
54 fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
55 -s ${SPLASH_THEMES}/${SPLASH_THEME}/startup-${resolution}.ppm.gz \
56 -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
57 -f ${SPLASH_FIFO} \
58 ${SPLASH_OPTS} &
59
60 wait_for_fbsplash
61 splash_control "write:${SPLASH_BOOT_MESSAGE}"
62 fi
63
64 if [[ ${runlevel} = shutdown ]]
65 then
66 fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
67 -s ${SPLASH_THEMES}/${SPLASH_THEME}/shutdown-${resolution}.ppm.gz \
68 -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
69 -f ${SPLASH_FIFO} \
70 ${SPLASH_OPTS} &
71
72 wait_for_fbsplash
73 splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}"
74 fi
75
76 if [[ $runlevel = reboot ]]
77 then
78 fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
79 -s ${SPLASH_THEMES}/${SPLASH_THEME}/reboot-${resolution}.ppm.gz \
80 -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
81 -f ${SPLASH_FIFO} \
82 ${SPLASH_OPTS} &
83
84 wait_for_fbsplash
85 splash_control "write:${SPLASH_REBOOT_MESSAGE}"
86 fi
87 fi
88 }
89
90 rc_exit()
91 {
92 if [[ ${SPLASH_MODE} = silent ]]
93 then
94 splash_control "exit"
95 splash_cursor enable
96 if [[ -n ${SPLASH_X11_TTY} ]]
97 then
98 chvt ${SPLASH_X11_TTY}
99 else
100 chvt 1
101 fi
102 fi
103 }
104
105 splash_resolution()
106 {
107 fbres
108 }
109
110 wait_for_fbsplash()
111 {
112 while [[ -z $(pidof fbsplash) ]]
113 do
114 sleep 0.1
115 done
116 }
117
118 splash_control()
119 {
120 # only write to fifo if the fbsplash process is runnning
121 # or the console will hang
122 if [[ -n $(pidof fbsplash) ]]
123 then
124 echo "$@" > ${SPLASH_FIFO}
125 else
126 # exit here
127 splash_cursor enable
128 chvt 1
129 fi
130 }
131
132 # disable|enable
133 splash_cursor()
134 {
135 case $1 in
136 enable) echo -e "\e[?0c";;
137 disable) echo -e "\e[?1c" ;;
138 esac
139 }