_localectl revision c4c12f133e22af6e3e193f3312e7cad61fa1b881
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas#compdef localectl
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas_localectl_set-locale() {
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local -a _confs _locales
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local expl suf
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _locales=( ${(f)"$(_call_program locales "$service" list-locales)"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _confs=( ${${(f)"$(_call_program confs "locale 2>/dev/null")"}%\=*} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas if [[ -prefix 1 *\= ]]; then
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local conf=${PREFIX%%\=*}
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas compset -P1 '*='
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _wanted locales expl "locales configs" \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _combination localeconfs confs=$conf locales "$@" -
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas compadd -S '=' $_confs
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas_localectl_set-keymap() {
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local -a _keymaps
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _keymaps=( ${(f)"$(_call_program locales "$service" list-keymaps)"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas if (( CURRENT <= 3 )); then
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _describe keymaps _keymaps
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _message "no more options"
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas_localectl_set-x11-keymap() {
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas if (( $+commands[pkg-config] )); then
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local -a _file _layout _model _variant _options
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local _xorg_lst
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _xorg_lst=${"$($commands[pkg-config] xkeyboard-config --variable=xkb_base)"}
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _file=( ${(ps:\n\!:)"$(<$_xorg_lst/rules/xorg.lst)"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _layout=( ${${${(M)${(f)_file[1]}:# *}# }%% *} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _model=( ${${${(M)${(f)_file[2]}:# *}# }%% *} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _variant=( ${${${(M)${(f)_file[3]}:# *}# }%% *} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _options=( ${${${(M)${(f)_file[4]}:# *}# }%% *} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas #_layout=( ${(f)"$( echo $_file[1] | awk '/^ / {print $1}' )"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas #_model=( ${(f)"$(echo $_file[2] | awk '/^ / {print $1}')"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas #_variant=( ${(f)"$(echo $_file[3] | awk '/^ / {print $1}')"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas #_options=( ${(f)"$(echo ${_file[4]//:/\\:} | awk '/^ / {print $1}')"} )
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas case $CURRENT in
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 2) _describe layouts _layout ;;
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 3) _describe models _model;;
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 4) _describe variants _variant;;
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 5) _describe options _options;;
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas *) _message "no more options"
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas_localectl_command() {
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local -a _localectl_cmds
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _localectl_cmds=(
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'status:Show current locale settings'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'set-locale:Set system locale'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'list-locales:Show known locales'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'set-keymap:Set virtual console keyboard mapping'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'list-keymaps:Show known virtual console keyboard mappings'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'set-x11-keymap:Set X11 keyboard mapping'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas if (( CURRENT == 1 )); then
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _describe -t commands 'localectl command' _localectl_cmds
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas local curcontext="$curcontext"
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas cmd="${${_localectl_cmds[(r)$words[1]:*]%%:*}}"
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas if (( $+functions[_localectl_$cmd] )); then
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _localectl_$cmd
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _message "no more options"
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas_hosts_or_user_at_host() {
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas _alternative \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'users-hosts:: _user_at_host' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas 'hosts:: _hosts'
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas {-h,--help}'[Show this help]' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas '--version[Show package version]' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas "--no-convert[Don't convert keyboard mappings]" \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas '--no-pager[Do not pipe output into a pager]' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas '--no-ask-password[Do not prompt for password]' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas {-H,--host=}'[Operate on remote host]:userathost:_hosts_or_user_at_host' \
c4c12f133e22af6e3e193f3312e7cad61fa1b881William Giokas '*::localectl commands:_localectl_command'