56 lines
2.2 KiB
Text
56 lines
2.2 KiB
Text
#compdef c4ctrl c4ctrl.py
|
|
|
|
# zsh completion script for c4ctrl.
|
|
#
|
|
# Last updated: 2017 Apr 17
|
|
# Author: Shy
|
|
# License: This file is placed in the public domain.
|
|
|
|
local -a preset_rooms
|
|
|
|
preset_rooms=( wohnzimmer plenar fnord keller )
|
|
|
|
_arguments -s \
|
|
'(-h --help)'{-h,--help}'[show help message and exit]' \
|
|
'(-d --debug)'{-d,--debug}'[show what would be send to the broker but do not connect]' \
|
|
'(-s --status)'{-s,--status}'[display club status]' \
|
|
'(-g --gate)'{-g,--gate}'[open gate]' \
|
|
'(-S --shutdown)'{-S,--shutdown}'[shutdown (twice forces shutdown)]' \
|
|
'(-k --kl-mode)'{-k,--kl-mode}'[set Kitchenlight mode]:Kitchenlight mode:(off checker matrix mood oc pacman sine text flood clock)' \
|
|
'(-i --list-kl-modes)'{-i,--list-kl-modes}'[list Kitchenlight modes)]' \
|
|
'(-w --wohnzimmer)'{-w,--wohnzimmer}'[apply a preset to room Wohnzimmer]:preset:->presets_read' \
|
|
'(-p --plenarsaal)'{-p,--plenarsaal}'[apply a preset to room Plenarsaal]:preset->presets_read' \
|
|
'(-f --fnordcenter)'{-f,--fnordcenter}'[apply a preset to room Fnordcenter]:preset:->presets_read' \
|
|
'(-m --magic)'{-m,--magic}'[use magic when switching presets]' \
|
|
'(-l --list-presets)'{-l,--list-presets}'[list presets]' \
|
|
'(-o --store-preset)'{-o,--store-preset}'[store current state as preset]:preset name:->presets_write' \
|
|
'-W[switch lights in Wohnzimmer]::switch code:( )' \
|
|
'-P[switch lights in Plenarsaal]::switch code:( )' \
|
|
'-F[switch lights in Fnordcenter]::switch code:( )' \
|
|
'-K[switch lights in Keller]::switch code:( )' \
|
|
'-r[activate remote preset]:remote preset:( )::room:(${preset_rooms[@]})' \
|
|
'-R[list remote presets]::room:(${preset_rooms[@]})'
|
|
|
|
|
|
case "$state" in
|
|
presets*)
|
|
local ret=0 c4ctrl_cfg_dir
|
|
if [[ "$XDG_CONFIG_DIR" ]]; then
|
|
c4ctrl_cfg_dir="$XDG_CONFIG_DIR/c4ctrl"
|
|
else
|
|
c4ctrl_cfg_dir="$HOME/.config/c4ctrl"
|
|
fi
|
|
if [[ -d "$c4ctrl_cfg_dir" ]]; then
|
|
if [[ "$state" == "presets_read" ]]; then
|
|
# 'off' and 'random' are builtins and always 'readable'.
|
|
_values Presets 'off' 'random'
|
|
ret=$?
|
|
fi
|
|
_files -W "$c4ctrl_cfg_dir"
|
|
ret=$((ret+?))
|
|
return ret
|
|
fi
|
|
return 1
|
|
;;
|
|
esac
|
|
|