#!/bin/sh
#
# Univention Configuration Registry
#  keyboard mapping between X and rdp
#
# Like what you see? Join us!
# https://www.univention.com/about-us/careers/vacancies/
#
# Copyright 2004-2022 Univention GmbH
#
# https://www.univention.de/
#
# All rights reserved.
#
# The source code of this program is made available
# under the terms of the GNU Affero General Public License version 3
# (GNU AGPL V3) as published by the Free Software Foundation.
#
# Binary versions of this program provided by Univention to you as
# well as other copyrighted, protected or trademarked materials like
# Logos, graphics, fonts, specific documentations and configurations,
# cryptographic keys etc. are subject to a license agreement between
# you and Univention and not subject to the GNU AGPL V3.
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <https://www.gnu.org/licenses/>.

case "$1" in
	--xtordp|--x2rdp)
		case "$2" in
			al) #Albanian
				output=common #FIXME
				;;
			en_US) #American
				output=en-us
				;;
			ar) #Arabic
				output=ar
				;;
			am) #Armenian
				output=common #FIXME
				;;
			by) #Belarusian
				output=common #FIXME
				;;
			be) #Belgian
				output=fr-be
				;;
			be) #Bengali
				output=common #FIXME
				;;
			br) #Brazilian
				output=common #FIXME
				;;
			mm) #Burmese
				output=common #FIXME
				;;
			kan) #Canada
				output=fr-ca
				;;
			hr) #Croatian
				output=hr
				;;
			bg) #Cyrillic (bg)
				output=common #FIXME
				;;
			sr) #Cyrillic (sr)
				output=common #FIXME
				;;
			cz) #Czech
				output=common #FIXME
				;;
			cz_qwerty) #Czech (qwerty)
				output=common #FIXME
				;;
			dk) #Danish
				output=da
				;;
			dvorak) #Dvorak
				output=common #FIXME
				;;
			ee) #Estonian
				output=common #FIXME
				;;
			fi) #Finnish
				output=fi
				;;
			fr) #French
				output=fr
				;;
			fr-latin9) #French (fr-latin9)
				output=common #FIXME
				;;
			ge_la) #Georgian (ge_la)
				output=common #FIXME
				;;
			ge_ru) #Georgian (ge_ru)
				output=common #FIXME
				;;
			de) #Germany
				output=de
				;;
			gb) #Great Britain
				output=en-gb
				;;
			guj) #Gujarati
				output=common #FIXME
				;;
			guj) #Gujarati
				output=common #FIXME
				;;
			gur) #Gurmukhi
				output=common #FIXME
				;;
			dev) #Hindi
				output=common #FIXME
				;;
			el) #ISO8859-7 Greek
				output=common #FIXME
				;;
			is) #Icelandic
				output=is
				;;
			iu) #Inuktitut
				output=common #FIXME
				;;
			ir) #Iranian
				output=common #FIXME
				;;
			ie) #Irish
				output=common #FIXME
				;;
			il) #Israelian
				output=common #FIXME
				;;
			il_phonetic) #Israelian (phonetic)
				output=common #FIXME
				;;
			it) #Italian
				output=it
				;;
			lo) #Lao
				output=common #FIXME
				;;
			la) #Latin American
				output=common #FIXME
				;;
			lv) #Latvian
				output=lv
				;;
			lt) #Lithuanian
				output=lt
				;;
			mk) #Macedonian
				output=mk
				;;
			ml) #Malayalam
				output=common #FIXME
				;;
			mt) #Maltese
				output=common #FIXME
				;;
			mt_us) #Maltese (US layout)
				output=common #FIXME
				;;
			nl) #Nederland
				output=nl
				;;
			latin) #Northern Europe
				output=common #FIXME
				;;
			no) #Norwegian
				output=no
				;;
			ogham) #Ogham
				output=common #FIXME
				;;
			ori) #Oriya
				output=common #FIXME
				;;
			pc) #PC-Type
				output=common #FIXME
				;;
			pl) #Polish
				output=pl
				;;
			pl2) #Polish (qwerty)
				output=common #FIXME
				;;
			pt) #Portuguese
				output=pt
				;;
			ro) #Romanian
				output=common #FIXME
				;;
			ru) #Russian
				output=ru
				;;
			sapmi) #Samegiella
				output=common #FIXME
				;;
			sk) #Slovak
				output=common #FIXME
				;;
			sk_qwerty) #Slovak (qwerty)
				output=common #FIXME
				;;
			si) #Slovene
				output=sl
				;;
			es) #Spanish
				output=es
				;;
			se) #Swedish
				output=sv
				;;
			syr) #Syriac
				output=common #FIXME
				;;
			syr_phonetic) #Syriac (phonetic)
				output=common #FIXME
				;;
			tj) #Tajik
				output=common #FIXME
				;;
			tml) #Tamil
				output=common #FIXME
				;;
			tel) #Telugu
				output=common #FIXME
				;;
			th) #Thai
				output=th
				;;
			tr) #Turkish
				output=tr
				;;
			ua) #Ukrainian
				output=common #FIXME
				;;
			us) #United States
				output=common #FIXME
				;;
			yu) #Yugoslav
				output=common #FIXME
				;;
			*)
				output=en-us
				;;
		esac
		;;
	*)
		cat <<-EOL >&2

		Syntax:  univention-keyboardmapping --xtordp <x-keymap>
		Example: univention-keyboardmapping --xtordp gb

		Returns corresponding rdesktop-keymap to stdout

		EOL
		exit 255
		;;
esac

echo "$output"
