File: fbsplash

package info (click to toggle)
hibernate 1.07-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 316 kB
  • ctags: 52
  • sloc: sh: 1,014; makefile: 33
file content (144 lines) | stat: -rw-r--r-- 3,940 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet

AddConfigHandler FBSplashOptions
AddConfigHelp "FBSplash <boolean>" "Showing script progress using fbsplash. No kernel patches are required, but you will need the fbsplash splashutils package installed (distinct from the bootsplash splashutils package). You will almost certainly need to enable SwitchToTextMode as well, else your screen might end up garbled."
AddConfigHelp "FBSplashTheme <themename>" "FBSplash theme name (default is \"suspend2\")"


# default fbsplash theme config file
FBSPLASH_THEME="suspend2"

FBSPLASH_FIFO="/lib/splash/cache/.splash"

TimedFBSplashCtl() {
    # Write to the splash daemon fifo, but don't let it take more than a
    # second (implying that there is no longer a splash daemon there).
    (
    (
    /bin/echo -ne "$@" > $FBSPLASH_FIFO &
    echo_pid=$!
    sleep 1
    kill -9 $echo_pid > /dev/null 2>&1
    ) < /dev/null > /dev/null 2>&1 &
    )
}

FBSplashProgress() {
    if [ x"$USE_FBSPLASH" = "x1" ] ; then
	FBSPLASH_PROGRESS=$(($FBSPLASH_PROGRESS+6553));
	TimedFBSplashCtl "progress $(($FBSPLASH_PROGRESS))\nrepaint\n"
    fi
    return 0
}

FBSplashBegin() {
    [ x"$USE_FBSPLASH" != "x1" ] && return 0

    # check if splash_util exists
    if ! command -v splash_util > /dev/null 2>&1 ; then
	USE_FBSPLASH=0
	vecho 1 "'splash_util' utility not found. fbsplash disabled."
	return 0
    fi

    # configfile exists
    if [ ! -d "/etc/splash/$FBSPLASH_THEME/" ]; then
	USE_FBSPLASH=0
	vecho 1 "config file not found. fbsplash disabled."
	return 0
    fi

    # Start up the splash daemon.
    mkdir -p `dirname $FBSPLASH_FIFO`
    rm -f $FBSPLASH_FIFO > /dev/null 2>&1
    if ! splash_util -t $FBSPLASH_THEME -d ; then
	USE_FBSPLASH=0
	vecho 0 "Splash daemon failed to start. fbsplash disabled."
	return 0
    fi
    if ! test -p $FBSPLASH_FIFO ; then
	USE_FBSPLASH=0
	vecho 0 "Could not talk to splash daemon. fbsplash disabled."
	return 0
    fi
    TimedFBSplashCtl "progress 0\nset message $@\nrepaint\n"

    # Set console loglevel to KERN_CRIT whilst suspending
    SAVED_FBSPLASH_PRINTK_LEVEL=`awk '{print $1}' < /proc/sys/kernel/printk`
    echo 2 > /proc/sys/kernel/printk

    # increments the bar to 10 and kicks it all off.
    FBSPLASH_PROGRESS=0
    FBSplashProgress

    return 0
}

FBSplashStartResume() {
    FBSplashBegin "Recovering from resume ..."
}

FBSplashStartSuspend() {
    FBSPLASH_INIT_VT=`fgconsole` || FBSPLASH_INIT_VT=1
    FBSplashBegin "Preparing to suspend ..."
}

FBSplashOff() {
    TimedFBSplashCtl "exit\n"

    # Gah, this hack shouldn't be required:
    sleep 0.5
    TimedFBSplashCtl "exit\n"

    [ -n "$SAVED_FBSPLASH_PRINTK_LEVEL" ] && \
	echo $SAVED_FBSPLASH_PRINTK_LEVEL > /proc/sys/kernel/printk

    return 0
}

FBSplashOptions() {
    case $1 in
	fbsplash)
	    BoolIsOn "$1" "$2" && USE_FBSPLASH=1 || return 0
	    # don't return. still stuff to do
	    ;;
	fbsplashtheme)
	    FBSPLASH_THEME="$2"
	    return 0
	    ;;
	*)
	    return 1
    esac

    if [ -z "$FBSPLASH_HOOKED" ] ; then
	# in call order
	AddSuspendHook 12 FBSplashStartSuspend
	AddSuspendHook 20 FBSplashProgress
	AddSuspendHook 30 FBSplashProgress
	AddSuspendHook 40 FBSplashProgress
	AddSuspendHook 50 FBSplashProgress
	AddSuspendHook 60 FBSplashProgress
	AddSuspendHook 70 FBSplashProgress
	AddSuspendHook 80 FBSplashProgress
	AddSuspendHook 90 FBSplashProgress
	AddSuspendHook 95 FBSplashProgress
	AddSuspendHook 95 FBSplashOff
	AddResumeHook 95 FBSplashStartResume
	AddResumeHook 90 FBSplashProgress
	AddResumeHook 80 FBSplashProgress
	AddResumeHook 70 FBSplashProgress
	AddResumeHook 60 FBSplashProgress
	AddResumeHook 50 FBSplashProgress
	AddResumeHook 40 FBSplashProgress
	AddResumeHook 30 FBSplashProgress
	AddResumeHook 20 FBSplashProgress
	AddResumeHook 15 FBSplashProgress # get it to 100% :)
	AddResumeHook 12 FBSplashOff
	FBSPLASH_HOOKED=1
    fi

    return 0
}

# $Id: fbsplash 870 2005-04-04 04:55:05Z bernard $