#!/bin/sh
# Filename:      grml-lang
# Purpose:       load specific keyboard layout settings
# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
# Bug-Reports:   see http://grml.org/bugs/
# License:       This file is licensed under the GPL v2.
# Latest change: Fri Apr 21 02:02:54 CEST 2006 [mika]
################################################################################

usage(){
    echo "Usage: $0 <language>"
    echo "supported values: at, de, ch, us"
}

if [ $# -lt "1" ] ; then
   usage
   exit -1
fi

if [ -z "$DISPLAY" ] ;then
  if [ "$1" = "de" ] ; then
    echo "Loading keymap for Germany..."
    sudo loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz
    echo -e "\nDone."
  elif [ "$1" = "at" ] ; then
    echo "Loading keymap for Austria..."
    sudo loadkeys i386/qwertz/de-latin1-nodeadkeys.kmap.gz
    echo -e "\nDone."
  elif [ "$1" = "ch" ] ; then
    echo "Loading keymap for Switzerland..."
    sudo loadkeys i386/qwertz/sg-latin1.kmap.gz
    echo -e "\nDone."
  elif [ "$1" = "us" ] ; then
    echo 'Loading keymap us...'
    # sudo loadkeys /etc/console/boottime.kmap.gz
    sudo loadkeys i386/qwerty/us-latin1.kmap.gz
    echo -e "\nDone."
  else echo "No valid parameter given.

Notice: Use loadkeys on console and setxkbmap when running X for
modifying keyboard layout. Adjust \$LANG and \$LC_ALL for setting locales." ; exit 1
  fi
else
  if [ $# = 0 ] ; then
      echo "Usage: $0 <language>"
      echo "supported values: at, de, ch, us"
  else
    if [ "$1" = "de" ] ; then
      echo "Loading keymap for Germany..."
      [ -r $HOME/.Xmodmap.german ] && xmodmap $HOME/.Xmodmap.german || setxkbmap de
      echo -e "\nDone."
    elif [ "$1" = "at" ] ; then
      echo "Loading keymap for Austria..."
      setxkbmap de
      echo -e "\nDone."
    elif [ "$1" = "ch" ] ; then
      echo "Loading keymap for Switzerland..."
      setxkbmap ch
      echo -e "\nDone."
    elif [ "$1"  = "us" ] ; then
      echo 'Loading keymap us...'
      [ -r $HOME/.Xmodmap ] && xmodmap $HOME/.Xmodmap || setxkbmap us
      echo -e "\nDone."
    else
      echo "No valid parameter given."
      echo
      usage
      echo
      echo "Notice: Use loadkeys on console and setxkbmap when running X for
modifying keyboard layout. Adjust \$LANG and \$LC_ALL for setting locales." ; exit 1
    fi
  fi
fi

## END OF FILE #################################################################
