xref: /onnv-gate/usr/src/cmd/loadkeys/set_keyboard_layout (revision 6193:f29bdfdca7ab)
10Sstevel@tonic-gate#! /usr/bin/sh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
61031Sdm89450# Common Development and Distribution License (the "License").
71031Sdm89450# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
22668Sdm89450#pragma ident	"%Z%%M%	%I%	%E% SMI"
230Sstevel@tonic-gate#
24*6193Sja208388# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2598Sdm89450# Use is subject to license terms.
260Sstevel@tonic-gate#
270Sstevel@tonic-gate
281307Sqz150045# get the valid layout name from the eeprom and set it into kernel.
291307Sqz150045# check space and tab to make sure that the kbd -s interaction mode
301307Sqz150045# doesn't run here.
313505Sqz150045KBD_LAYOUT_NVRAM_EXIST="`/usr/sbin/eeprom | grep keyboard-layout`"
323505Sqz150045
333505Sqz150045if test -n "$KBD_LAYOUT_NVRAM_EXIST"
343505Sqz150045then
353505Sqz150045	KBD_LAYOUT_NAME="`/usr/sbin/eeprom keyboard-layout |\
363505Sqz150045			/usr/bin/sed -n 's/keyboard-layout=//g; s/[ |	]*//p'`"
373505Sqz150045else
383505Sqz150045	exit 0
393505Sqz150045fi
400Sstevel@tonic-gate
41*6193Sja208388# The firmware on the keyboard may report "Taiwanese" and so
42*6193Sja208388# translate it to the new "Traditional-Chinese" name as this is
43*6193Sja208388# the preferred name to use.
44*6193Sja208388if [ "$KBD_LAYOUT_NAME" = "Taiwanese" ]
45*6193Sja208388then
46*6193Sja208388       KBD_LAYOUT_NAME="Traditional-Chinese"
47*6193Sja208388fi
48*6193Sja208388
491307Sqz150045if test -n "$KBD_LAYOUT_NAME"
501307Sqz150045then
513256Sqz150045	KBD_LAYOUT_NAME_STRING="^$KBD_LAYOUT_NAME="
523256Sqz150045	LAYOUT_NAME_VALID="`cat /usr/share/lib/keytables/type_6/kbd_layouts | \
533505Sqz150045                   	grep "$KBD_LAYOUT_NAME_STRING"`"
543256Sqz150045else
553256Sqz150045	exit 0
563256Sqz150045fi
573256Sqz150045
583256Sqz150045if test -n "$LAYOUT_NAME_VALID"
593256Sqz150045then
601307Sqz150045	# Set the keyboard layout
611307Sqz150045	/usr/bin/kbd -s $KBD_LAYOUT_NAME
621307Sqz150045fi
63