#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/keymaps,v 1.15 2003/01/21 22:05:07 azarah Exp $


depend() {
	need localmount
}

checkconfig() {
	if [ -z "${KEYMAP}" ]
	then
		eerror "You need to setup \$KEYMAP in /etc/rc.conf first"
		return 1
	fi
}

start() {
	checkconfig || return 1

	# Force linux keycodes for PPC ...
	if [ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]
	then
		echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes
	fi
	
	ebegin "Loading key mappings"
	
	# Enable unicode ...
	set -- ${KEYMAP}
	if [ "$1" = "-u" ]
	then
		/usr/bin/kbd_mode -u
	fi
	
	# New kbd support ...
	if [ -x /bin/loadkeys ]
	then
		/bin/loadkeys -q windowkeys ${KEYMAP} >/dev/null
	# Old console-tools support ...
	elif [ -x /usr/bin/loadkeys ]
	then
		/usr/bin/loadkeys -q windowkeys.inc ${KEYMAP} >/dev/null
	else
		eend 1 "loadkeys executable not found"
		return 1
	fi
	eend $? "Error loading key mappings"
}


# vim:ts=4
