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