xref: /freebsd/libexec/rc/rc.d/moused (revision f586fc0cf8ff54393a3db565437788a12bdc6e99)
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=
19typearg=
20load_rc_config $name
21
22# doesn't make sense to run in a svcj: nojail keyword
23# XXX: How does moused communiacte with the kernel?
24# XXX: Does the kernel prevent this communcation in jails?
25moused_svcj="NO"
26
27# Set the pid file and variable name. The second argument, if it exists, is
28# expected to be the mouse device.
29#
30if [ -n "$2" ]; then
31	ms=`basename $2`
32	eval moused_${ms}_enable=\${moused_${ms}_enable-${moused_nondefault_enable}}
33	rcvar="moused_${ms}_enable"
34	pidfile="${pidprefix}.${ms}.pid"
35	pidarg="-I $pidfile"
36fi
37
38moused_start()
39{
40	local ms myflags myport mytype
41
42	# Set the mouse device and get any related variables. If
43	# a moused device has been specified on the commandline, then
44	# rc.conf(5) variables defined for that device take precedence
45	# over the generic moused_* variables. The only exception is
46	# the moused_port variable, which if not defined sets it to the
47	# passed in device name.
48	#
49	if [ -n "$1" ]; then
50		ms=`basename $1`
51		eval myflags=\${moused_${ms}_flags-$moused_flags}
52		eval myport=\${moused_${ms}_port-/dev/$1}
53		eval mytype=\${moused_${ms}_type-$moused_type}
54		if [ -n "$mytype" ] && check_kern_features evdev_support; then
55			typearg="-t ${mytype}"
56		fi
57	else
58		ms="default"
59		myflags="$moused_flags"
60		myport="$moused_port"
61	fi
62
63	startmsg -n "Starting ${ms} moused"
64	/usr/sbin/moused ${myflags} -p ${myport} ${typearg} ${pidarg}
65	startmsg '.'
66
67	mousechar_arg=
68	case ${mousechar_start} in
69	[Nn][Oo] | '')
70		;;
71	*)
72		mousechar_arg="-M ${mousechar_start}"
73		;;
74	esac
75
76	for ttyv in /dev/ttyv* ; do
77		[ "$ttyv" = '/dev/ttyv*' ] && break
78		vidcontrol < ${ttyv} ${mousechar_arg} -m on
79	done
80}
81
82run_rc_command $*
83