_blugon () {
	local args opts
	local cur prev

	local backends backendopts


	args=(
		"-h" "--help"
		"-v" "--version"
		"-V" "--verbose"
		"-p" "--printconfig"
		"-o" "--once"
		"-r" "--readcurrent"
		"-S" "--setcurrent"
		"-s" "--simulation"
		"-f" "--fade"
		"-i" "--interval"
		"-c" "--configdir"
		"-b" "--backend"
		"-w" "--waitforx"
	)

	backends=(
		"xgamma"
		"scg"
		"tty"
	)

	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	opts="${args[@]}"

	backendopts="${backends[@]}"

	case "${prev}" in
		"-S"|"--setcurrent")
			COMPREPLY=()
			;;
		"-i"|"--interval")
			COMPREPLY=()
			;;
		"-c"|"--configdir")
			COMPREPLY=( $(compgen -d -- "${cur}") )
			;;
		"-b"|"--backend")
			COMPREPLY=( $(compgen -W "${backendopts}" -- "${cur}") )
			;;
		*)
			case "${cur}" in
				"-"*)
					COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
					;;
				*)
					COMPREPLY=()
					;;
			esac
			;;
	esac
}

complete -F _blugon blugon
