File: fbsplash

package info (click to toggle)
hibernate 2.0%2B15%2Bg88d54a8-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 740 kB
  • ctags: 114
  • sloc: sh: 1,223; makefile: 17
file content (150 lines) | stat: -rw-r--r-- 4,208 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
145
146
147
148
149
150
# -*- 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). This will automatically enable SwitchToTextMode too."
AddConfigHelp "FBSplashTheme <themename>" "FBSplash theme name (default is taken from /proc/cmdline)"


# default fbsplash theme config file
FBSPLASH_THEME=""

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

    [ -z "$FBSPLASH_THEME" ] && FBSPLASH_THEME="$(grep splash= /proc/cmdline > /dev/null && cat /proc/cmdline | sed 's/.*splash=/splash=/' | sed 's/ .*//' | sed 's/.*theme://' | sed 's/,.*//' || echo default)"

    # check if fbsplashd exists
    if ! command -v fbsplashd > /dev/null 2>&1 ; then
	USE_FBSPLASH=0
	vecho 1 "'fbsplashd' 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

    if ! test -p $FBSPLASH_FIFO ; then
	USE_FBSPLASH=0
	vecho 0 "Could not talk to splash daemon. fbsplash disabled."
	return 0
    fi

    # Start up the splash daemon.
    if ! fbsplashd --theme $FBSPLASH_THEME --mesg "Suspending..." --effects "fadein" ; then
	USE_FBSPLASH=0
	vecho 0 "Splash daemon failed to start. fbsplash disabled."
	return 0
    fi
    TimedFBSplashCtl "set mode silent\nprogress 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() {
    TimedFBSplashCtl "set tty silent 2\nset mode silent\nset theme $FBSPLASH_THEME\nrepaint\n"
    TimedFBSplashCtl "set message Reloading drivers and applications ...\nrepaint\n"
    FBSPLASH_PROGRESS=0
    FBSplashProgress
}

FBSplashStartSuspend() {
    FBSplashBegin "Preparing to suspend ..."
}

FBSplashOff() {
    TimedFBSplashCtl "set effects fadeout\n"
    TimedFBSplashCtl "exit\n"

    while killall -q -0 fbsplashd; do
    	sleep 1
    done

    [ -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 94 FBSplashProgress
	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

	# Enable SwitchToTextMode too.
	XHacksOptions switchtotextmode 1
    fi

    return 0
}

# $Id$