#!/bin/bash

# Select a keyboard layout in a menu

outfile=${1:-/dev/stdout}
. /usr/sbin/dialog-helper

trap "exit 1" SIGINT

layouts=$(find /usr/lib/kbd/keymaps/ -type f |sed -e '/map.gz/!d' -e "s:.*/\(.*\).map.gz:\1:" | sort -u)
dialog_helper --no-items --menu "Choose your keyboard layout" 100 30 100 $(for i in $layouts ; do echo "$i"; done)

cat << EOC > $outfile
$(echo "$DIALOGRES")
EOC

exit 0
