# loadkeys for gido

_loadkeys()
{
  local cur short_opts long_opts maps
  COMPREPLY=()
  cur="${COMP_WORDS[COMP_CWORD]}"
  short_opts="-a -b -c -C -d -h -m -q -s -u -v"
  long_opts="--ascii --bkeymap --clearcompose --console --default --help 
             --mktable --quiet --clearstrings --unicode --verbose"
  if [[ ${cur} == --* ]] ; then
    COMPREPLY=( $(compgen -W "${long_opts}" -- ${cur}) )
    return 0
  elif [[ ${cur} == -* ]] ; then
    COMPREPLY=( $(compgen -W "${short_opts}" -- ${cur}) )
    return 0
  elif [[ ${cur} ]] ; then
    maps=$(find /lib/kbd/keymaps/ -iname *.map.gz -exec basename {} .map.gz \;|sort)
    COMPREPLY=( $(compgen -W "${maps}" ${cur}) )
    return 0
  fi
}
complete -F _loadkeys loadkeys
