xref: /dragonfly/etc/rc.d/moused (revision 31524921)
1#!/bin/sh
2#
3# $FreeBSD: head/etc/rc.d/moused 240336 2012-09-11 05:04:59Z obrien $
4#
5
6# PROVIDE: moused
7# REQUIRE: DAEMON
8
9. /etc/rc.subr
10
11name=moused
12rcvar=`set_rcvar`
13command="/usr/sbin/${name}"
14start_cmd="moused_start"
15pidprefix="/var/run/moused"
16pidfile="${pidprefix}.pid"
17pidarg=
18load_rc_config $name
19
20# Set the pid file and variable name. The second argument, if it exists, is
21# expected to be the mouse device.
22#
23if [ -n "$2" ]; then
24	eval moused_$2_enable=\${moused_$2_enable-${moused_nondefault_enable}}
25	rcvar="moused_${2}_enable"
26	pidfile="${pidprefix}.$2.pid"
27	pidarg="-I $pidfile"
28fi
29
30moused_start()
31{
32	# Set the mouse device and get any related variables. If
33	# a moused device has been specified on the commandline, then
34	# rc.conf(5) variables defined for that device take precedence
35	# over the generic moused_* variables. The only exception is
36	# the moused_port variable, which if not defined sets it to the
37	# passed in device name.
38	#
39	ms=$1
40	if [ -n "$ms" ]; then
41		eval myflags=\${moused_${ms}_flags-$moused_flags}
42		eval myport=\${moused_${ms}_port-/dev/$ms}
43		eval mytype=\${moused_${ms}_type-$moused_type}
44	else
45		ms="default"
46		myflags="$moused_flags"
47		myport="$moused_port"
48		mytype="$moused_type"
49	fi
50
51	check_startmsgs && echo -n "Starting ${ms} moused"
52	/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
53	check_startmsgs && echo '.'
54
55	mousechar_arg=
56	case ${mousechar_start} in
57	[Nn][Oo] | '')
58		;;
59	*)
60		mousechar_arg="-M ${mousechar_start}"
61		;;
62	esac
63
64	for ttyv in /dev/ttyv* ; do
65		vidcontrol < ${ttyv} ${mousechar_arg} -m on
66	done
67}
68
69run_rc_command $*
70