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