#compdef wl-screenrec

autoload -U is-at-least

_wl-screenrec() {
    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[@]}" : \
'-f+[filename to write to. container type is detected from extension]:FILENAME:_default' \
'--filename=[filename to write to. container type is detected from extension]:FILENAME:_default' \
'-g+[geometry to capture, format x,y WxH. Compatible with the output of \`slurp\`. Mutually exclusive with --output]:GEOMETRY:_default' \
'--geometry=[geometry to capture, format x,y WxH. Compatible with the output of \`slurp\`. Mutually exclusive with --output]:GEOMETRY:_default' \
'-o+[Which output (display) to record. Mutually exclusive with --geometry. Defaults to your only display if you only have one]:OUTPUT:_default' \
'--output=[Which output (display) to record. Mutually exclusive with --geometry. Defaults to your only display if you only have one]:OUTPUT:_default' \
'-m+[limit maximum framerate into the encoder. Note that by default, wl-screenrec only copies frames when the contents have changed, so it can drop below this]:MAX_FPS:_default' \
'--max-fps=[limit maximum framerate into the encoder. Note that by default, wl-screenrec only copies frames when the contents have changed, so it can drop below this]:MAX_FPS:_default' \
'--dri-device=[which dri device to use for vaapi. by default, this is obtained from the linux-dmabuf-v1 protocol when using wlr-screencopy, and from ext-image-copy-capture-session if using ext-image-copy-capture, if present. if not present, /dev/dri/renderD128 is guessed]:DRI_DEVICE:_default' \
'--low-power=[]:LOW_POWER:(auto on off)' \
'--codec=[which video codec to use. Ignored if \`--ffmpeg-encoder\` is supplied]:CODEC:(auto avc hevc vp8 vp9 av1)' \
'--ffmpeg-muxer=[Which ffmpeg muxer to use. Guessed from output filename by default]:FFMPEG_MUXER:_default' \
'--ffmpeg-muxer-options=[Options to pass to the muxer. Format looks like key=val,key2=val2]:FFMPEG_MUXER_OPTIONS:_default' \
'--ffmpeg-encoder=[Use this to force a particular ffmpeg encoder. Generally, this is not necessary and the combo of --codec and --hw can get you to where you need to be]:FFMPEG_ENCODER:_default' \
'--ffmpeg-encoder-options=[Options to pass to the encoder. Format looks like key=val,key2=val2]:FFMPEG_ENCODER_OPTIONS:_default' \
'--audio-codec=[Which audio codec to use. Ignored if \`--ffmpeg-audio-encoder\` is supplied]:AUDIO_CODEC:(auto aac mp3 flac opus)' \
'--audio-bitrate=[audio bitrate to encode at. Unit is bytes per second, 16 kB is 128 kbps]:AUDIO_BITRATE:_default' \
'--ffmpeg-audio-encoder=[Use this to force a particular audio ffmpeg encoder. By default, this is guessed from the muxer (which is guess by the file extension if --ffmpeg-muxer isn'\''t passed)]:FFMPEG_AUDIO_ENCODER:_default' \
'--encode-pixfmt=[which pixel format to encode with. not all codecs will support all pixel formats. This should be a ffmpeg pixel format string, like nv12 or x2rgb10. If the encoder supports vaapi memory, it will use this pixel format type but in vaapi memory]:ENCODE_PIXFMT:_default' \
'--encode-resolution=[what resolution to encode at. example\: 1920x1080. Default is the resolution of the captured region. If your goal is reducing filesize, it'\''s suggested to try --bitrate/-b first]:ENCODE_RESOLUTION:_default' \
'-b+[bitrate to encode at. Unit is bytes per second, so 5 MB is 40 Mbps]:BITRATE:_default' \
'--bitrate=[bitrate to encode at. Unit is bytes per second, so 5 MB is 40 Mbps]:BITRATE:_default' \
'--history=[run in a mode where the screen is recorded, but nothing is written to the output file until SIGUSR1 is sent to the process. Then, it writes the most recent N seconds to a file and continues recording]:HISTORY:_default' \
'--audio-device=[which audio device to record from. list devices with \`pactl list short sources\`]:AUDIO_DEVICE:_default' \
'--audio-backend=[which ffmpeg audio capture backend (see https\://ffmpeg.org/ffmpeg-devices.html\`) to use. you almost certainally want to specify --audio-device if you use this, as the values depend on the backend used]:AUDIO_BACKEND:_default' \
'--gop-size=[GOP (group of pictures) size]:GOP_SIZE:_default' \
'--generate-completions=[print completions for the specified shell to stdout]:COMPLETIONS_GENERATOR:(bash elvish fish powershell zsh)' \
'--capture-backend=[which capture backend to use]:CAPTURE_BACKEND:(auto wlr-screencopy ext-image-copy-capture)' \
'--no-hw[don'\''t use the GPU encoder, download the frames onto the CPU and use a software encoder. Ignored if \`encoder\` is supplied]' \
'--no-cursor[don'\''t capture the cursor]' \
'*-v[add very loud logging. can be specified multiple times]' \
'*--verbose[add very loud logging. can be specified multiple times]' \
'--audio[record audio with the stream. Defaults to the default audio capture device]' \
'--no-damage[copy every frame, not just unique frames. This can be helpful to get a non-variable framerate video, but is generally discouraged as it uses much more resources. Useful for testing]' \
'--experimental-vulkan[use vulkan allocator & encode]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
}

(( $+functions[_wl-screenrec_commands] )) ||
_wl-screenrec_commands() {
    local commands; commands=()
    _describe -t commands 'wl-screenrec commands' commands "$@"
}

if [ "$funcstack[1]" = "_wl-screenrec" ]; then
    _wl-screenrec "$@"
else
    compdef _wl-screenrec wl-screenrec
fi
