Skip to content

Conversation

@bschatz
Copy link

@bschatz bschatz commented Mar 29, 2020

device options (-dv -dp -ds -tuk) not finished, yet.

@MatMoul
Copy link
Owner

MatMoul commented Apr 10, 2020

Good idea but don't work very well

@dioni21
Copy link
Contributor

dioni21 commented Sep 12, 2020

Will there be any more work on this?

@bschatz
Copy link
Author

bschatz commented Sep 12, 2020

if somebody finds it useful i could spend a little bit more time here.

@MatMoul
Copy link
Owner

MatMoul commented Sep 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants