summaryrefslogtreecommitdiff
blob: 3ac9a34c9d307afcc2056a5e8e4a7bbc02c26dad (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/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-freebsd/freebsd-usbin/files/moused.initd,v 1.3 2007/02/23 14:03:08 uberlord Exp $

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 :