g810-led
g810-led copied to clipboard
bash completion
device options (-dv -dp -ds -tuk) not finished, yet.
Good idea but don't work very well
Will there be any more work on this?
if somebody finds it useful i could spend a little bit more time here.
this is mine :
#/usr/bin/env bash
_g810-led_completions(){
local -r devargs="-dv -dp -ds -tuk"
local -r infoargs="--list-keyboards --print-device --help --help-keys --help-effects --help-samples"
local -r args="-a -an -g -gn -k -kn -c -fx -p --startup-mode"
local -r keygroups="logo indicators fkeys modifiers multimedia arrows numeric functions keys"
local -r startupmode="wave color"
local -r effects="color breathing cycle waves hwave vwave cwave"
local -r effecttargets="all keys logo"
local -r tukopts="1 2 3"
local -r cur=${COMP_WORDS[COMP_CWORD]}
if [[ ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=($(compgen -W "${infoargs} ${devargs} ${args}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
fi
if [[ ${COMP_CWORD} -gt 1 ]] ; then
case "${COMP_WORDS[COMP_CWORD-1]}" in
"-g" | "-gn")
COMPREPLY=($(compgen -W "${keygroups}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
"-fx")
COMPREPLY=($(compgen -W "${effects}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
"-p")
_filedir
return 0
;;
"--startup-mode")
COMPREPLY=($(compgen -W "${startupmode}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
"-tuk")
COMPREPLY=($(compgen -W "${tukopts}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
esac
fi
if [[ ${COMP_CWORD} -gt 2 ]] ; then
case "${COMP_WORDS[COMP_CWORD-2]}" in
"-dv" | "-dp" | "-ds" | "-tuk")
local curargs="${devargs} ${args}"
for ((i=0; i<=COMP_CWORD; i++)); do
case "${COMP_WORDS[i]}" in
"-dv" | "-dp" | "-ds" | "-tuk") curargs=${curargs//${COMP_WORDS[i]}/};;
esac
done
COMPREPLY=($(compgen -W "${curargs}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
"-fx")
COMPREPLY=($(compgen -W "${effecttargets}" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
;;
esac
fi
return 0
}
complete -F _g810-led_completions g213-led
complete -F _g810-led_completions g410-led
complete -F _g810-led_completions g413-led
complete -F _g810-led_completions g512-led
complete -F _g810-led_completions g513-led
complete -F _g810-led_completions g610-led
complete -F _g810-led_completions g810-led
complete -F _g810-led_completions g910-led
complete -F _g810-led_completions gpro-led