aboutsummaryrefslogtreecommitdiff
path: root/libexec/rc/rc.d/moused
blob: e267ae5b3cd82db0c25e2ad0d5605ea2d92a563e (plain) (blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/sh
#
#

# PROVIDE: moused
# REQUIRE: DAEMON FILESYSTEMS
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="moused"
desc="Mouse daemon"
rcvar="moused_enable"
command="/usr/sbin/${name}"
start_cmd="moused_start"
pidprefix="/var/run/moused"
pidfile="${pidprefix}.pid"
pidarg=
typearg=
load_rc_config $name

# doesn't make sense to run in a svcj: nojail keyword
# XXX: How does moused communiacte with the kernel?
# XXX: Does the kernel prevent this communcation in jails?
moused_svcj="NO"

# Set the pid file and variable name. The second argument, if it exists, is
# expected to be the mouse device.
#
if [ -n "$2" ]; then
	ms=`basename $2`
	eval moused_${ms}_enable=\${moused_${ms}_enable-${moused_nondefault_enable}}
	rcvar="moused_${ms}_enable"
	pidfile="${pidprefix}.${ms}.pid"
	pidarg="-I $pidfile"
fi

moused_start()
{
	local ms myflags myport mytype

	# Set the mouse device and get any related variables. If
	# a moused device has been specified on the commandline, then
	# rc.conf(5) variables defined for that device take precedence
	# over the generic moused_* variables. The only exception is
	# the moused_port variable, which if not defined sets it to the
	# passed in device name.
	#
	if [ -n "$1" ]; then
		ms=`basename $1`
		eval myflags=\${moused_${ms}_flags-$moused_flags}
		eval myport=\${moused_${ms}_port-/dev/$1}
		eval mytype=\${moused_${ms}_type-$moused_type}
		if [ -n "$mytype" ] && check_kern_features evdev_support; then
			typearg="-t ${mytype}"
		fi
	else
		ms="default"
		myflags="$moused_flags"
		myport="$moused_port"
	fi

	startmsg -n "Starting ${ms} moused"
	/usr/sbin/moused ${myflags} -p ${myport} ${typearg} ${pidarg}
	startmsg '.'

	mousechar_arg=
	case ${mousechar_start} in
	[Nn][Oo] | '')
		;;
	*)
		mousechar_arg="-M ${mousechar_start}"
		;;
	esac

	for ttyv in /dev/ttyv* ; do
		[ "$ttyv" = '/dev/ttyv*' ] && break
		vidcontrol < ${ttyv} ${mousechar_arg} -m on
	done
}

run_rc_command $*