xref: /illumos-gate/usr/src/cmd/loadkeys/set_keyboard_layout (revision e4603304e8bd084dd25a0dbafdd438ac250d5f56)
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*e4603304Sqz150045# Copyright 2007 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.
31*e4603304Sqz150045KBD_LAYOUT_NVRAM_EXIST="`/usr/sbin/eeprom | grep keyboard-layout`"
32*e4603304Sqz150045
33*e4603304Sqz150045if test -n "$KBD_LAYOUT_NVRAM_EXIST"
34*e4603304Sqz150045then
35fe539fb3Sqz150045	KBD_LAYOUT_NAME="`/usr/sbin/eeprom keyboard-layout |\
36fe539fb3Sqz150045			/usr/bin/sed -n 's/keyboard-layout=//g; s/[ |	]*//p'`"
37*e4603304Sqz150045else
38*e4603304Sqz150045	exit 0
39*e4603304Sqz150045fi
407c478bd9Sstevel@tonic-gate
41fb620828Sqz150045if test -n "$KBD_LAYOUT_NAME"
42fb620828Sqz150045then
43fe539fb3Sqz150045	KBD_LAYOUT_NAME_STRING="^$KBD_LAYOUT_NAME="
44fe539fb3Sqz150045	LAYOUT_NAME_VALID="`cat /usr/share/lib/keytables/type_6/kbd_layouts | \
45*e4603304Sqz150045                   	grep "$KBD_LAYOUT_NAME_STRING"`"
46fe539fb3Sqz150045else
47fe539fb3Sqz150045	exit 0
48fe539fb3Sqz150045fi
49fe539fb3Sqz150045
50fe539fb3Sqz150045if test -n "$LAYOUT_NAME_VALID"
51fe539fb3Sqz150045then
52fb620828Sqz150045	# Set the keyboard layout
537db6e34eSqz150045	/usr/bin/kbd -s $KBD_LAYOUT_NAME
54fb620828Sqz150045fi
55