xref: /illumos-gate/usr/src/cmd/loadkeys/set_keyboard_layout (revision fe539fb313fcf38628fdaadef98c79a8c5beee37)
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#
247db6e34eSqz150045# Copyright 2006 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*fe539fb3Sqz150045KBD_LAYOUT_NAME="`/usr/sbin/eeprom keyboard-layout |\
32*fe539fb3Sqz150045                 /usr/bin/sed -n 's/keyboard-layout=//g; s/[ |	]*//p'`"
337c478bd9Sstevel@tonic-gate
34fb620828Sqz150045if test -n "$KBD_LAYOUT_NAME"
35fb620828Sqz150045then
36*fe539fb3Sqz150045	KBD_LAYOUT_NAME_STRING="^$KBD_LAYOUT_NAME="
37*fe539fb3Sqz150045	LAYOUT_NAME_VALID="`cat /usr/share/lib/keytables/type_6/kbd_layouts | \
38*fe539fb3Sqz150045                   	grep $KBD_LAYOUT_NAME_STRING`"
39*fe539fb3Sqz150045else
40*fe539fb3Sqz150045	exit 0
41*fe539fb3Sqz150045fi
42*fe539fb3Sqz150045
43*fe539fb3Sqz150045if test -n "$LAYOUT_NAME_VALID"
44*fe539fb3Sqz150045then
45fb620828Sqz150045	# Set the keyboard layout
467db6e34eSqz150045	/usr/bin/kbd -s $KBD_LAYOUT_NAME
47fb620828Sqz150045fi
48