summaryrefslogtreecommitdiff
blob: d7ca8e0fcf0a22edc43d5c9e07ec206bc1a0f489 (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
#!/sbin/openrc-run
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

MOUSED_NAME=${SVCNAME##*.}
if [ -n "${MOUSED_NAME}" ] && [ ${MOUSED_NAME} != "moused" ] ; then
	MOUSED_DEVICE=/dev/"${MOUSED_NAME}"
	MOUSED_PIDFILE=/var/run/moused-"${MOUSED_NAME}".pid
else
	MOUSED_NAME=
	MOUSED_PIDFILE=/var/run/moused.pid
fi

depend() {
	need localmount 
}

start() {
	ebegin "Starting the Console Mouse Daemon" "${MOUSED_NAME}"

	if [ -z ${MOUSED_DEVICE} ] ; then
		for x in /dev/psm[0-9]* /dev/ums[0-9]* ; do
			if [ -e "${x}" ] && \
			[ ! -e /var/run/moused-$(basename "${x}").pid ] ; then
				MOUSED_DEVICE=${x}
				eindent
				einfo "Using mouse on ${MOUSED_DEVICE}"
				eoutdent
				break
			fi
		done
	fi

	if [ -z "${MOUSED_DEVICE}" ] ; then
		eend 1 "No device specified in" "/etc/conf.d/${SVCNAME}" \
			"and no mouse detected"
		return 1
	fi

	local opts="${MOUSED_FLAGS} -p ${MOUSED_DEVICE}"
	start-stop-daemon --start --quiet --exec /usr/sbin/moused \
		--pidfile "${MOUSED_PIDFILE}" \
		-- ${opts} -I "${MOUSED_PIDFILE}"
	local retval=$?
	
	[ -n "${MOUSE_CHAR_START}" ] && MOUSE_CHAR_START="-M ${MOUSE_CHAR_START}"
	local ttyv=
	for ttyv in /dev/ttyv* ; do
		vidcontrol < "${ttyv}" ${MOUSE_CHAR_START} -m on || retval=1
	done
	
	eend ${retval} "Failed to start moused"
}

stop() {
	ebegin "Stopping the Console Mouse Daemon" "${MOUSED_NAME}"
	# Don't specify the binary as >1 instance of moused may be running
	# which is perfectly valid as we can be multiplexed.
	start-stop-daemon --stop --exec /usr/sbin/moused \
		--pidfile "${MOUSED_PIDFILE}"
	eend $? "Failed to stop moused"
}

# vim: set ts=4 :