Annotation of /trunk/busybox/splash-functions.rc
Parent Directory | Revision Log
Revision 1839 -
(hide annotations)
(download)
Fri Jul 13 09:55:49 2012 UTC (12 years, 2 months ago) by niro
File size: 3389 byte(s)
Fri Jul 13 09:55:49 2012 UTC (12 years, 2 months ago) by niro
File size: 3389 byte(s)
-introduce SPLASH_DEV config opt and use it
1 | niro | 1264 | # /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 | niro | 1279 | local cmd |
9 | local args | ||
10 | |||
11 | # check for a framebuffer console first! | ||
12 | niro | 1839 | [[ ! -e ${SPLASH_DEV} ]] && return 0 |
13 | niro | 1279 | # proc must be mounted too |
14 | [[ ! -e /proc/cmdline ]] && return 0 | ||
15 | niro | 1275 | # only run fbsplash if theme was found |
16 | [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME} ]] && return | ||
17 | niro | 1279 | # and run only if a config for the current resolution exist |
18 | [[ ! -e ${SPLASH_THEMES}/${SPLASH_THEME}/$(splash_resolution).conf ]] && return | ||
19 | niro | 1275 | |
20 | niro | 1398 | # create fifo if not exist |
21 | if [[ ! -w ${SPLASH_FIFO} ]] | ||
22 | then | ||
23 | mkfifo ${SPLASH_FIFO} | ||
24 | fi | ||
25 | |||
26 | niro | 1279 | # check cmdline for config_opts |
27 | # splash=silent,theme:mcore | ||
28 | for cmd in $(< /proc/cmdline) | ||
29 | do | ||
30 | case "${cmd}" in | ||
31 | splash=*) | ||
32 | # split the cmd and put everything into an array | ||
33 | args=( $(echo "${cmd}" | sed 's:[,\:=]:\ :g') ) | ||
34 | # mode is always args[1] | ||
35 | SPLASH_MODE="${args[1]}" | ||
36 | # theme is always args[3] | ||
37 | SPLASH_THEME="${args[3]}" | ||
38 | ;; | ||
39 | esac | ||
40 | done | ||
41 | |||
42 | niro | 1264 | case $1 in |
43 | rc_init) rc_init ;; | ||
44 | rc_verbose|rc_exit) rc_exit ;; | ||
45 | niro | 1744 | # redraw splash image and text |
46 | svc_started) | ||
47 | if [[ ${runlevel} = boot ]] || [[ ${runlevel} = sysinit ]] | ||
48 | then | ||
49 | splash_control "image:" | ||
50 | splash_control "write:${SPLASH_BOOT_MESSAGE}" | ||
51 | fi | ||
52 | ;; | ||
53 | svc_stopped) | ||
54 | if [[ ${runlevel} = shutdown ]] | ||
55 | then | ||
56 | splash_control "image:" | ||
57 | splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}" | ||
58 | fi | ||
59 | if [[ ${runlevel} = reboot ]] | ||
60 | then | ||
61 | splash_control "image:" | ||
62 | splash_control "write:${SPLASH_REBOOT_MESSAGE}" | ||
63 | fi | ||
64 | ;; | ||
65 | niro | 1264 | esac |
66 | } | ||
67 | |||
68 | rc_init() | ||
69 | { | ||
70 | if [[ ${SPLASH_MODE} = silent ]] | ||
71 | then | ||
72 | local resolution="$(splash_resolution)" | ||
73 | |||
74 | chvt ${SPLASH_TTY} | ||
75 | niro | 1276 | sleep 0.5 |
76 | niro | 1264 | |
77 | niro | 1744 | if [[ ${runlevel} = boot ]] || [[ ${runlevel} = sysinit ]] |
78 | niro | 1264 | then |
79 | fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \ | ||
80 | -s ${SPLASH_THEMES}/${SPLASH_THEME}/startup-${resolution}.ppm.gz \ | ||
81 | -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \ | ||
82 | -f ${SPLASH_FIFO} \ | ||
83 | niro | 1839 | -d ${SPLASH_DEV} \ |
84 | niro | 1264 | ${SPLASH_OPTS} & |
85 | |||
86 | niro | 1275 | wait_for_fbsplash |
87 | niro | 1264 | splash_control "write:${SPLASH_BOOT_MESSAGE}" |
88 | fi | ||
89 | |||
90 | if [[ ${runlevel} = shutdown ]] | ||
91 | then | ||
92 | fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \ | ||
93 | -s ${SPLASH_THEMES}/${SPLASH_THEME}/shutdown-${resolution}.ppm.gz \ | ||
94 | -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \ | ||
95 | -f ${SPLASH_FIFO} \ | ||
96 | niro | 1839 | -d ${SPLASH_DEV} \ |
97 | niro | 1264 | ${SPLASH_OPTS} & |
98 | |||
99 | niro | 1275 | wait_for_fbsplash |
100 | niro | 1264 | splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}" |
101 | fi | ||
102 | |||
103 | niro | 1744 | if [[ ${runlevel} = reboot ]] |
104 | niro | 1264 | then |
105 | fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \ | ||
106 | -s ${SPLASH_THEMES}/${SPLASH_THEME}/reboot-${resolution}.ppm.gz \ | ||
107 | -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \ | ||
108 | -f ${SPLASH_FIFO} \ | ||
109 | niro | 1839 | -d ${SPLASH_DEV} \ |
110 | niro | 1264 | ${SPLASH_OPTS} & |
111 | |||
112 | niro | 1275 | wait_for_fbsplash |
113 | niro | 1264 | splash_control "write:${SPLASH_REBOOT_MESSAGE}" |
114 | fi | ||
115 | fi | ||
116 | } | ||
117 | |||
118 | rc_exit() | ||
119 | { | ||
120 | if [[ ${SPLASH_MODE} = silent ]] | ||
121 | then | ||
122 | splash_control "exit" | ||
123 | niro | 1277 | if [[ -n ${SPLASH_X11_TTY} ]] |
124 | then | ||
125 | chvt ${SPLASH_X11_TTY} | ||
126 | else | ||
127 | chvt 1 | ||
128 | fi | ||
129 | niro | 1264 | fi |
130 | } | ||
131 | |||
132 | splash_resolution() | ||
133 | { | ||
134 | fbres | ||
135 | } | ||
136 | |||
137 | niro | 1275 | wait_for_fbsplash() |
138 | { | ||
139 | while [[ -z $(pidof fbsplash) ]] | ||
140 | do | ||
141 | sleep 0.1 | ||
142 | done | ||
143 | } | ||
144 | |||
145 | niro | 1264 | splash_control() |
146 | { | ||
147 | # only write to fifo if the fbsplash process is runnning | ||
148 | # or the console will hang | ||
149 | if [[ -n $(pidof fbsplash) ]] | ||
150 | then | ||
151 | echo "$@" > ${SPLASH_FIFO} | ||
152 | fi | ||
153 | } |