diff options
author | mtm <mtm@FreeBSD.org> | 2004-11-01 18:05:41 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2004-11-01 18:05:41 +0000 |
commit | 94c6d19c80ab9f3b68faee1c4679f1bb07a91e58 (patch) | |
tree | 1f980b3b84807a4c4cbf80e41a031cc40ab2fac8 /etc/rc.d/moused | |
parent | 9464f7f21640bcee55e4e2ceeeb6124ad065e51c (diff) | |
download | FreeBSD-src-94c6d19c80ab9f3b68faee1c4679f1bb07a91e58.zip FreeBSD-src-94c6d19c80ab9f3b68faee1c4679f1bb07a91e58.tar.gz |
Do a better job of supporting more than one mouse device
on the system.
To start/stop/check on a specific device give the device name as
the second argument to the script:
# /etc/rc.d/moused start ums0
To use different rc.conf(5) knobs with different mice use the device
name as part of the knob. For example, if the mouse device is ums0, then:
moused_ums0_enable=yes
moused_ums0_flags="-z 4"
moused_ums0_port="/dev/ums0"
Starting rc.d/moused without the device argument will use the standard
moused_* flags. So, this commit should not disrupt or change current usage.
To preserve current behaviour with respect to usb mice, which appear
automatically when inserted, there is a new knob, moused_nondefault_enable,
which will treat any devices without rc.conf knobs as enabled.
To minimize knobs in /etc/rc.conf, the device file and pid file are
auto-computed, so that in the typical case for a usb mouse you don't
need to add anything extra in /etc/rc.conf to get it working.
Additionally, this updates /etc/usbd.conf to use the rc.d/moused script so
people don't have to modify it to configure their usb mouse anymore.
MFC after: 1 month
Diffstat (limited to 'etc/rc.d/moused')
-rw-r--r-- | etc/rc.d/moused | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/etc/rc.d/moused b/etc/rc.d/moused index 9ef5ee5..9d35a05 100644 --- a/etc/rc.d/moused +++ b/etc/rc.d/moused @@ -14,11 +14,47 @@ name=moused rcvar=`set_rcvar` command="/usr/sbin/${name}" start_cmd="moused_start" +_pidprefix="/var/run/moused" +pidfile="${_pidprefix}.pid" +_pidarg= +load_rc_config $name + +# Set the pid file and variable name. The second argument, if it exists, is +# expected to be the mouse device. +# +if [ -n "$2" ]; then + checkyesno moused_nondefault_enable && + eval moused_$2_enable=\${moused_$2_enable-YES} + rcvar=`set_rcvar moused_$2` + pidfile="${_pidprefix}.$2.pid" + _pidarg="-I $pidfile" +fi moused_start() { - echo -n 'Starting moused:' - /usr/sbin/moused ${moused_flags} -p ${moused_port} -t ${moused_type} + 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. + # + ms=$1 + if [ -n "$ms" ]; then + eval myflags=\${moused_${ms}_flags-$moused_flags} + eval myport=\${moused_${ms}_port-/dev/$ms} + eval mytype=\${moused_${ms}_type-$moused_type} + else + ms="default" + myflags="$moused_flags" + myport="$moused_port" + mytype="$moused_type" + fi + + echo -n "Starting ${ms} moused:" + /usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${_pidarg} _mousechar_arg= case ${mousechar_start} in @@ -36,5 +72,4 @@ moused_start() echo '.' } -load_rc_config $name -run_rc_command "$1" +run_rc_command $* |