xref: /titanic_41/usr/src/cmd/loadkeys/set_keyboard_layout (revision c24275a9bcbb4724f5dfc1d56a4b03c89195203f)
17c478bd9Sstevel@tonic-gate#! /usr/bin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6577f006cSdm89450# Common Development and Distribution License (the "License").
7577f006cSdm89450# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
22f95bda13Sdm89450#pragma ident	"%Z%%M%	%I%	%E% SMI"
237c478bd9Sstevel@tonic-gate#
24*c24275a9Sja208388# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
2548784e40Sdm89450# Use is subject to license terms.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate
28fb620828Sqz150045# get the valid layout name from the eeprom and set it into kernel.
29fb620828Sqz150045# check space and tab to make sure that the kbd -s interaction mode
30fb620828Sqz150045# doesn't run here.
31e4603304Sqz150045KBD_LAYOUT_NVRAM_EXIST="`/usr/sbin/eeprom | grep keyboard-layout`"
32e4603304Sqz150045
33e4603304Sqz150045if test -n "$KBD_LAYOUT_NVRAM_EXIST"
34e4603304Sqz150045then
35fe539fb3Sqz150045	KBD_LAYOUT_NAME="`/usr/sbin/eeprom keyboard-layout |\
36fe539fb3Sqz150045			/usr/bin/sed -n 's/keyboard-layout=//g; s/[ |	]*//p'`"
37e4603304Sqz150045else
38e4603304Sqz150045	exit 0
39e4603304Sqz150045fi
407c478bd9Sstevel@tonic-gate
41*c24275a9Sja208388# The firmware on the keyboard may report "Taiwanese" and so
42*c24275a9Sja208388# translate it to the new "Traditional-Chinese" name as this is
43*c24275a9Sja208388# the preferred name to use.
44*c24275a9Sja208388if [ "$KBD_LAYOUT_NAME" = "Taiwanese" ]
45*c24275a9Sja208388then
46*c24275a9Sja208388       KBD_LAYOUT_NAME="Traditional-Chinese"
47*c24275a9Sja208388fi
48*c24275a9Sja208388
49fb620828Sqz150045if test -n "$KBD_LAYOUT_NAME"
50fb620828Sqz150045then
51fe539fb3Sqz150045	KBD_LAYOUT_NAME_STRING="^$KBD_LAYOUT_NAME="
52fe539fb3Sqz150045	LAYOUT_NAME_VALID="`cat /usr/share/lib/keytables/type_6/kbd_layouts | \
53e4603304Sqz150045                   	grep "$KBD_LAYOUT_NAME_STRING"`"
54fe539fb3Sqz150045else
55fe539fb3Sqz150045	exit 0
56fe539fb3Sqz150045fi
57fe539fb3Sqz150045
58fe539fb3Sqz150045if test -n "$LAYOUT_NAME_VALID"
59fe539fb3Sqz150045then
60fb620828Sqz150045	# Set the keyboard layout
617db6e34eSqz150045	/usr/bin/kbd -s $KBD_LAYOUT_NAME
62fb620828Sqz150045fi
63