Re: [PATCH] kbdmux(4) and devd(8)

From: Maksim Yevmenkin <maksim.yevmenkin_at_savvis.net>
Date: Thu, 02 Mar 2006 11:04:41 -0800
Dear Hackers,

any comments/objections/etc. to the attached patch? the idea is to 
prevent devd(8) from trying to switch keyboards when kbdmux(4) is the 
default keyboard.

thanks,
max



Index: etc/devd.conf
===================================================================
RCS file: /home/ncvs/src/etc/devd.conf,v
retrieving revision 1.30
diff -u -r1.30 devd.conf
--- etc/devd.conf	11 Dec 2005 00:18:28 -0000	1.30
+++ etc/devd.conf	2 Mar 2006 18:56:55 -0000
_at__at_ -99,11 +99,11 _at__at_
 # When a USB keyboard arrives, attach it as the console keyboard.
 attach 100 {
 	device-name "ukbd0";
-	action "kbdcontrol -k /dev/ukbd0 < /dev/console && /etc/rc.d/syscons restart";
+	action "/etc/rc.d/syscons setkeyboard /dev/ukbd0 && /etc/rc.d/syscons restart";
 };
 detach 100 {
 	device-name "ukbd0";
-	action "kbdcontrol -k /dev/kbd0 < /dev/console";
+	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
 };
 
 # The entry below starts moused when a mouse is plugged in. Moused
Index: etc/rc.d/syscons
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/syscons,v
retrieving revision 1.14
diff -u -r1.14 syscons
--- etc/rc.d/syscons	15 Dec 2005 01:04:48 -0000	1.14
+++ etc/rc.d/syscons	2 Mar 2006 18:56:55 -0000
_at__at_ -34,6 +34,8 _at__at_
 . /etc/rc.subr
 
 name="syscons"
+extra_commands="setkeyboard"
+setkeyboard_cmd="syscons_setkeyboard"
 start_precmd="syscons_precmd"
 start_cmd="syscons_start"
 
_at__at_ -42,6 +44,21 _at__at_
 kbddev=/dev/ttyv0
 viddev=/dev/ttyv0
 
+syscons_setkeyboard()
+{
+	kbd=$1
+                
+	if [ -z "${kbd}" ]; then
+		return 1
+	fi
+
+	# Check if the kbdmux(4) is the current active keyboard
+	kbdcontrol -i < ${kbddev} | grep kbdmux > /dev/null 2>&1
+	if [ $? != 0 ]; then
+		kbdcontrol -k ${kbd} < ${kbddev} > /dev/null 2>&1
+	fi
+}
+
 syscons_precmd()
 {
 	if [ ! -c $kbddev ]
_at__at_ -62,8 +79,7 _at__at_
 	# keyboard
 	#
 	if [ -n "${keyboard}" ]; then
-		echo -n ' keyboard';	kbdcontrol < ${kbddev} \
-		    -k "${keyboard}" >/dev/null
+		echo -n ' keyboard';	syscons_setkeyboard ${keyboard}
 	fi
 
 	# keymap
_at__at_ -207,4 +223,5 _at__at_
 }
 
 load_rc_config $name
-run_rc_command "$1"
+run_rc_command $*
+
Received on Thu Mar 02 2006 - 18:04:49 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:53 UTC