summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/splashy/splashy-functions
blob: 037cb278a561870e843d5ec978e9fdb8087a8c4a (plain)
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
#
# splashy functions
#

# functions:

splashy_wait_till_ready() { debug_log "$0 ${FUNCNAME}"
	local tries=50

	/sbin/splashy_update "print" 2> /dev/null

	while [ $? -ne 0 ]; do
		[ $tries -ne 0 ] || return 1
		((tries--))
		sleep 0.1
		/sbin/splashy_update "print" 2> /dev/null
	done

	debug_log "tries=$((50-$tries))"
}

splashy_print() { debug_log "$0 ${FUNCNAME}"
	/sbin/splashy_update "print ${1}" 2> /dev/null
}

splashy_sysinit() { debug_log "$0 ${FUNCNAME}"
	splashy_wait_till_ready
}

splashy_multi() { debug_log "$0 ${FUNCNAME}"
	return 0
}

splashy_shutdown() { debug_log "$0 ${FUNCNAME}"
	clear > /dev/tty${1}
	/sbin/splashy_chvt ${1}

	splashy shutdown 2> /dev/null

	splashy_wait_till_ready
}

splashy_kill() { debug_log "$0 ${FUNCNAME}"
	local tries=50
	while pidof splashy > /dev/null; do
		[ $tries -ne 0 ] || return 1
		((tries--))

		kill -15 `pidof splashy`
		sleep 0.2
		pidof splashy > /dev/null || break
		kill -9 `pidof splashy`
		sleep 0.2
	done
	debug_log "tries=$((50-$tries))"
}

splashy_exit() { debug_log "$0 ${FUNCNAME}"
	pidof splashy > /dev/null || return 1

	/usr/bin/setterm -cursor off > /dev/tty8
	
	/sbin/splashy_update "progress 100" 2> /dev/null
	sleep 0.3
	/sbin/splashy_update "exit" 2> /dev/null
	sleep 0.3

	splashy_kill

	if [ "$(fgconsole 2>/dev/null)" = "${1}" ]; then
		clear > /dev/tty${1} || true
	fi

	/usr/bin/setterm -cursor off > /dev/tty7

	if [ -n "${2}" ]; then
		if [ "$(fgconsole 2>/dev/null)" != "${2}" ]; then 
			/sbin/splashy_chvt ${2} || true
		else
			# fall back to tty1
			/sbin/splashy_chvt 1 || true
		fi
	fi
}

splashy_progress() { debug_log "$0 ${FUNCNAME}"
	PROGRESS=$(((${1}*100)/${2}))
	/sbin/splashy_update "progress ${PROGRESS}" 2> /dev/null
}

# End of file
# vim: set ts=2 noet: