#compdef fuzzel

_arguments \
    -s \
    '(-v --version)'{-v,--version}'[show the version number and quit]' \
    '(-h --help)'{-h,--help}'[show help message and quit]' \
    '(-o --output)'{-o,--output}'[output (monitor) to display on (none)]:output:->outputs' \
    '(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
    '(-D --dpi-aware)'{-D,--dpi-aware}"[scale fonts using the monitor's DPI (auto)]:dpi_aware:(no yes auto)" \
    '(-i --icon-theme)'{-i,--icon-theme}'[icon theme name (hicolor)]:theme:->icon_theme' \
    '(-I --no-icons)'{-I,--no-icons}'[do not render any icons]' \
    '(-F --fields)'{-F,--fields}'[comma separated list of XDG Desktop entry fields to match ]:fields:->fields' \
    '(-T --terminal)'{-T,--terminal}'[terminal command, with arguments]:terminal:_command_names -e' \
    '(-l --lines)'{-l,--lines}'[maximum number of matches to display (15)]:()' \
    '(-w --width)'{-w,--width}'[window width, in characters (30)]:()' \
    '(-x --horizontal-pad)'{-x,--horizontal-pad}'[horizontal padding, in pixels (40)]:()' \
    '(-y --vertical-pad)'{-y,--vertical-pad}'[vertical padding, in pixels (8)]:()' \
    '(-p --inner-pad)'{-p,--inner-pad}'[vertical padding between prompt and matches, in pixels (0)]:()' \
    '(-b --background)'{-b,--background}'[background color (fdf6e3dd)]:background:()' \
    '(-t --text-color)'{-t,--text-color}'[text color (657b83ff)]:text-color:()' \
    '(-m --match-color)'{-m,--match-color}'[color of matched substring (cb4b16ff)]:match-color:()' \
    '(-s --selection-color)'{-s,--selection-color}'[background color of selected item (eee8d5dd)]:selection-color:()' \
    '(-S --selection-text-color)'{-S,--selection-text-color}'[text color of selected item (657b83ff)]:selection-text-color:()' \
    '(-B --border-width)'{-B,--border-width}'[width of border, in pixels (1)]:border-width:()' \
    '(-r --border-radius)'{-r,--border-radius}'[amount of corner "roundness" (10)]:border-radius:()' \
    '(-C --border-color)'{-C,--border-color}'[border color (002b36ff)]:border-color:()' \
    '--show-actions[include desktop actions (e.g "New Window") in the list]' \
    '--no-fuzzy[disable fuzzy matching]' \
    '--fuzzy-min-length[search strings shorter than this will not be fuzzy matched (3)]:()' \
    '--fuzzy-max-length-discrepancy[maximum allowed length difference between the search string and a fuzzy match (2)]:()' \
    '--fuzzy-max-distance[maximum allowed levenshtein distance between the search string and a fuzzy match (1)]:()' \
    '--line-height[override line height from font metrics, in points or pixels]:()' \
    '--letter-spacing[additional letter spacing, in points or pixels]:()' \
    '(-d --dmenu)'{-d,--dmenu}'[dmenu compatibility mode; list entries are read from stdin]' \
    "--index[print selected entry's index instead of its text (dmenu mode only)]" \
    '(-R --no-run-if-empty)'{-R,--no-run-if-empty}'[exit immediately without showing the UI if stdin is empty (dmenu mode only)]' \
    '--log-level[log level (info)]:loglevel:(info warning error none)' \
    '--log-colorize[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \
    '--log-no-syslog[disable syslog logging]'

case "${state}" in
    fonts)
        if command -v fc-list > /dev/null; then
            _values 'font families' $(fc-list : family | tr -d ' ')
        fi
        ;;

    icon_theme)
        _values 'icon themes' $(cd /usr/share/icons; echo *)
        ;;

    outputs)
        if command -v swaymsg > /dev/null; then
            _values 'outputs' $(swaymsg -t get_outputs --raw|grep name|cut -d '"' -f 4)
        fi
        ;;

    fields)
        _values -s , 'Desktop entry fields' filename name generic exec categories keywords comment
        ;;
esac
