#! /usr/bin/sh
#
# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
#
# get the valid layout name from the eeprom and set it into kernel.
# check space and tab to make sure that the kbd -s interaction mode
# doesn't run here.
KBD_LAYOUT_NVRAM_OUTPUT="`/usr/sbin/eeprom keyboard-layout`"
echo ${KBD_LAYOUT_NVRAM_OUTPUT} | grep -q "data not available"
if [ $? -eq 1 ]
then
KBD_LAYOUT_NAME="`echo ${KBD_LAYOUT_NVRAM_OUTPUT} |\
/usr/bin/sed -n 's/keyboard-layout=//g; s/[ | ]*//p'`"
else
exit 0
fi
# The firmware on the keyboard may report "Taiwanese" and so
# translate it to the new "Traditional-Chinese" name as this is
# the preferred name to use.
if [ "$KBD_LAYOUT_NAME" = "Taiwanese" ]
then
KBD_LAYOUT_NAME="Traditional-Chinese"
fi
if test -n "$KBD_LAYOUT_NAME"
then
KBD_LAYOUT_NAME_STRING="^$KBD_LAYOUT_NAME="
LAYOUT_NAME_VALID="`cat /usr/share/lib/keytables/type_6/kbd_layouts | \
grep "$KBD_LAYOUT_NAME_STRING"`"
else
exit 0
fi
if test -n "$LAYOUT_NAME_VALID"
then
# Set the keyboard layout
/usr/bin/kbd -s $KBD_LAYOUT_NAME
fi