#compdef swww

autoload -U is-at-least

_swww() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_swww_commands" \
"*::: :->swww" \
&& ret=0
    case $state in
    (swww)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:swww-command-$line[1]:"
        case $line[1] in
            (clear)
_arguments "${_arguments_options[@]}" \
'-o+[Comma separated list of outputs to display the image at]:OUTPUTS: ' \
'--outputs=[Comma separated list of outputs to display the image at]:OUTPUTS: ' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::color -- Color to fill the screen with:' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
'-o+[Comma separated list of outputs to restore]:OUTPUTS: ' \
'--outputs=[Comma separated list of outputs to restore]:OUTPUTS: ' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(clear-cache)
_arguments "${_arguments_options[@]}" \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(img)
_arguments "${_arguments_options[@]}" \
'-o+[Comma separated list of outputs to display the image at]:OUTPUTS: ' \
'--outputs=[Comma separated list of outputs to display the image at]:OUTPUTS: ' \
'--resize=[Whether to resize the image and the method by which to resize it]:RESIZE:((no\:"Do not resize the image"
crop\:"Resize the image to fill the whole screen, cropping out parts that don'\''t fit"
fit\:"Resize the image to fit inside the screen, preserving the original aspect ratio"))' \
'--fill-color=[Which color to fill the padding with when output image does not fill screen]:FILL_COLOR: ' \
'-f+[Filter to use when scaling images (run swww img --help to see options)]:FILTER: ' \
'--filter=[Filter to use when scaling images (run swww img --help to see options)]:FILTER: ' \
'-t+[Sets the type of transition. Default is '\''simple'\'', that fades into the new image]:TRANSITION_TYPE: ' \
'--transition-type=[Sets the type of transition. Default is '\''simple'\'', that fades into the new image]:TRANSITION_TYPE: ' \
'--transition-step=[How fast the transition approaches the new image]:TRANSITION_STEP: ' \
'--transition-duration=[How long the transition takes to complete in seconds]:TRANSITION_DURATION: ' \
'--transition-fps=[Frame rate for the transition effect]:TRANSITION_FPS: ' \
'--transition-angle=[This is used for the '\''wipe'\'' and '\''wave'\'' transitions. It controls the angle of the wipe]:TRANSITION_ANGLE: ' \
'--transition-pos=[This is only used for the '\''grow'\'','\''outer'\'' transitions. It controls the center of circle (default is '\''center'\'')]:TRANSITION_POS: ' \
'--transition-bezier=[bezier curve to use for the transition https\://cubic-bezier.com is a good website to get these values from]:TRANSITION_BEZIER: ' \
'--transition-wave=[currently only used for '\''wave'\'' transition to control the width and height of each wave]:TRANSITION_WAVE: ' \
'--no-resize[Do not resize the image. Equivalent to \`--resize=no\`]' \
'--invert-y[inverts the y position sent in '\''transiiton_pos'\'' flag]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':path -- Path to the image to display:_files' \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
'--format=[Force the daemon to use a specific wl_shm format]:FORMAT:((bgr\:"No swap, can copy directly onto WlBuffer"
rgb\:"Swap R and B channels at client, can copy directly onto WlBuffer"
xbgr\:"No swap, must extend pixel with an extra byte when copying"
xrgb\:"Swap R and B channels at client, must extend pixel with an extra byte when copying"))' \
'--no-daemon[Don'\''t fork the daemon. This will keep it running in the current terminal]' \
'--no-cache[Don'\''t load the cache *during initialization* (it still loads on monitor (re)connection)]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(kill)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(query)
_arguments "${_arguments_options[@]}" \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_swww__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:swww-help-command-$line[1]:"
        case $line[1] in
            (clear)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(clear-cache)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(img)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(init)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(kill)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(query)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_swww_commands] )) ||
_swww_commands() {
    local commands; commands=(
'clear:Fills the specified outputs with the given color' \
'restore:Restores the last displayed image on the specified outputs' \
'clear-cache:Clears the swww cache' \
'img:Sends an image (or animated gif) for the daemon to display' \
'init:\[DEPRECATED\] Initializes the daemon' \
'kill:Kills the daemon' \
'query:Asks the daemon to print output information (names and dimensions)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'swww commands' commands "$@"
}
(( $+functions[_swww__clear_commands] )) ||
_swww__clear_commands() {
    local commands; commands=()
    _describe -t commands 'swww clear commands' commands "$@"
}
(( $+functions[_swww__help__clear_commands] )) ||
_swww__help__clear_commands() {
    local commands; commands=()
    _describe -t commands 'swww help clear commands' commands "$@"
}
(( $+functions[_swww__clear-cache_commands] )) ||
_swww__clear-cache_commands() {
    local commands; commands=()
    _describe -t commands 'swww clear-cache commands' commands "$@"
}
(( $+functions[_swww__help__clear-cache_commands] )) ||
_swww__help__clear-cache_commands() {
    local commands; commands=()
    _describe -t commands 'swww help clear-cache commands' commands "$@"
}
(( $+functions[_swww__help_commands] )) ||
_swww__help_commands() {
    local commands; commands=(
'clear:Fills the specified outputs with the given color' \
'restore:Restores the last displayed image on the specified outputs' \
'clear-cache:Clears the swww cache' \
'img:Sends an image (or animated gif) for the daemon to display' \
'init:\[DEPRECATED\] Initializes the daemon' \
'kill:Kills the daemon' \
'query:Asks the daemon to print output information (names and dimensions)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'swww help commands' commands "$@"
}
(( $+functions[_swww__help__help_commands] )) ||
_swww__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'swww help help commands' commands "$@"
}
(( $+functions[_swww__help__img_commands] )) ||
_swww__help__img_commands() {
    local commands; commands=()
    _describe -t commands 'swww help img commands' commands "$@"
}
(( $+functions[_swww__img_commands] )) ||
_swww__img_commands() {
    local commands; commands=()
    _describe -t commands 'swww img commands' commands "$@"
}
(( $+functions[_swww__help__init_commands] )) ||
_swww__help__init_commands() {
    local commands; commands=()
    _describe -t commands 'swww help init commands' commands "$@"
}
(( $+functions[_swww__init_commands] )) ||
_swww__init_commands() {
    local commands; commands=()
    _describe -t commands 'swww init commands' commands "$@"
}
(( $+functions[_swww__help__kill_commands] )) ||
_swww__help__kill_commands() {
    local commands; commands=()
    _describe -t commands 'swww help kill commands' commands "$@"
}
(( $+functions[_swww__kill_commands] )) ||
_swww__kill_commands() {
    local commands; commands=()
    _describe -t commands 'swww kill commands' commands "$@"
}
(( $+functions[_swww__help__query_commands] )) ||
_swww__help__query_commands() {
    local commands; commands=()
    _describe -t commands 'swww help query commands' commands "$@"
}
(( $+functions[_swww__query_commands] )) ||
_swww__query_commands() {
    local commands; commands=()
    _describe -t commands 'swww query commands' commands "$@"
}
(( $+functions[_swww__help__restore_commands] )) ||
_swww__help__restore_commands() {
    local commands; commands=()
    _describe -t commands 'swww help restore commands' commands "$@"
}
(( $+functions[_swww__restore_commands] )) ||
_swww__restore_commands() {
    local commands; commands=()
    _describe -t commands 'swww restore commands' commands "$@"
}

if [ "$funcstack[1]" = "_swww" ]; then
    _swww "$@"
else
    compdef _swww swww
fi
