Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1398 - (hide annotations) (download)
Fri Jul 1 14:17:30 2011 UTC (12 years, 10 months ago) by niro
File size: 3039 byte(s)
-create fifo at runtime
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     [[ ! -e /dev/fb0 ]] && return 0
13     # 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     esac
46     }
47    
48     rc_init()
49     {
50     if [[ ${SPLASH_MODE} = silent ]]
51     then
52     local resolution="$(splash_resolution)"
53    
54     splash_cursor disable
55     chvt ${SPLASH_TTY}
56 niro 1276 sleep 0.5
57 niro 1264
58     if [[ $runlevel = boot ]] || [[ ${runlevel} = sysinit ]]
59     then
60     fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
61     -s ${SPLASH_THEMES}/${SPLASH_THEME}/startup-${resolution}.ppm.gz \
62     -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
63     -f ${SPLASH_FIFO} \
64     ${SPLASH_OPTS} &
65    
66 niro 1275 wait_for_fbsplash
67 niro 1264 splash_control "write:${SPLASH_BOOT_MESSAGE}"
68     fi
69    
70     if [[ ${runlevel} = shutdown ]]
71     then
72     fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
73     -s ${SPLASH_THEMES}/${SPLASH_THEME}/shutdown-${resolution}.ppm.gz \
74     -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
75     -f ${SPLASH_FIFO} \
76     ${SPLASH_OPTS} &
77    
78 niro 1275 wait_for_fbsplash
79 niro 1264 splash_control "write:${SPLASH_SHUTDOWN_MESSAGE}"
80     fi
81    
82     if [[ $runlevel = reboot ]]
83     then
84     fbsplash -i ${SPLASH_THEMES}/${SPLASH_THEME}/${resolution}.conf \
85     -s ${SPLASH_THEMES}/${SPLASH_THEME}/reboot-${resolution}.ppm.gz \
86     -m ${SPLASH_THEMES}/${SPLASH_THEME}/splash-font.gz \
87     -f ${SPLASH_FIFO} \
88     ${SPLASH_OPTS} &
89    
90 niro 1275 wait_for_fbsplash
91 niro 1264 splash_control "write:${SPLASH_REBOOT_MESSAGE}"
92     fi
93     fi
94     }
95    
96     rc_exit()
97     {
98     if [[ ${SPLASH_MODE} = silent ]]
99     then
100     splash_control "exit"
101     splash_cursor enable
102 niro 1277 if [[ -n ${SPLASH_X11_TTY} ]]
103     then
104     chvt ${SPLASH_X11_TTY}
105     else
106     chvt 1
107     fi
108 niro 1264 fi
109     }
110    
111     splash_resolution()
112     {
113     fbres
114     }
115    
116 niro 1275 wait_for_fbsplash()
117     {
118     while [[ -z $(pidof fbsplash) ]]
119     do
120     sleep 0.1
121     done
122     }
123    
124 niro 1264 splash_control()
125     {
126     # only write to fifo if the fbsplash process is runnning
127     # or the console will hang
128     if [[ -n $(pidof fbsplash) ]]
129     then
130     echo "$@" > ${SPLASH_FIFO}
131 niro 1275 else
132     # exit here
133     splash_cursor enable
134     chvt 1
135 niro 1264 fi
136     }
137    
138     # disable|enable
139     splash_cursor()
140     {
141     case $1 in
142     enable) echo -e "\e[?0c";;
143     disable) echo -e "\e[?1c" ;;
144     esac
145     }