1#compdef feh
2## completion for feh 1.6, based on feh(1)
3
4typeset -a arguments
5typeset -A argument_pairs argument_postfix
6typeset arg
7
8argument_pairs=(
9	'help'        'h'
10	'version'     'v'
11	'verbose'     'V'
12	'quiet'       'q'
13	'theme'       'T+'
14	'recursive'   'r'
15	'randomize'   'z'
16	'filelist'    'f+'
17	'preload'     'p'
18	'full-screen' 'F'
19	'geometry'    'g+'
20	'auto-zoom'   'Z'
21	'multiwindow' 'w'
22	'borderless'  'x'
23	'draw-filename' 'd'
24	'slideshow-delay' 'D+'
25	'reload'      'R+'
26	'keep-http'   'k'
27	'builtin'     'Q'
28	'list'        'l'
29	'customlist'  'L+'
30	'loadable'    'U'
31	'unloadable'  'u'
32	'sort'        'S+'
33	'reverse'     'n'
34	'action'      'A+'
35	'montage'     'm'
36	'collage'     'c'
37	'index'       'i'
38	'fullindex'   'I'
39	'thumbnails'  't'
40	'menu-font'   'M+'
41	'no-menus'    'N'
42	'reload-button' '0'
43	'menu-button' '3+'
44	'prev-button' '4+'
45	'next-button' '5+'
46	'rotate-button' '8+'
47	'blur-button' '9+'
48	'ignore-aspect' 'X'
49	'stretch'     's'
50	'thumb-width' 'y+'
51	'thumb-height' 'E+'
52	'limit-width' 'W+'
53	'limit-height' 'H+'
54	'bg'          'b+'
55	'alpha'       'a+'
56	'font'        'e+'
57	'scale-down'  '.'
58	'output-dir'  'j+'
59	'wget-timestamp' 'G'
60	'fontpath'    'C+'
61	'image-bg'    'B+'
62	'output'      'o'
63	'output-only' 'O'
64	'rcfile'      '_'
65	'thumb-title' '~'
66	'title'       '^'
67	'start-at'    '|'
68	'title-font'  '@'
69)
70
71argument_postfix=(
72	'help'        '[show help]'
73	'version'     '[show version information]'
74	'verbose'     '[be verbose]'
75	'quiet'       '[suppress non-fatal errors]'
76	'theme'       '[load named options from config]:theme:_feh_theme'
77	'recursive'   '[recurse into subdirectories]'
78	'randomize'   '[randomize file list before displaying]'
79	'filelist'    '[read file list from this file]:file:_files'
80	'preload'     '[eliminate unlaodable images before displaying]'
81	'full-screen' '[make the window fullscreen]'
82	'geometry'    '[limit window size]:geometry: '
83	'auto-zoom'   '[zoom picture to screen size]'
84	'multiwindow' '[multiple windows, one image per window]'
85	'borderless'  '[borderless windows]'
86	'draw-filename' '[show filename in images]'
87	'reload'      '[time delay for reloading]:time: '
88	'keep-http'   "[don't delete cached files]"
89	'builtin'     '[use builtin http client]'
90	'list'        '[list images, their size, etc.]'
91	'customlist'  '[format list output]:format: '
92	'loadable'    '[print loadable images]'
93	'unloadable'  '[print unloadable images]'
94	'sort'        '[sort images]:sort type:(name filename width height pixels size format)'
95	'reverse'     '[reverse sort order]'
96	'action'      '[action to perform on each image]:shell: '
97	'montage'     '[enable montage mode]'
98	'collage'     '[enable collage mode]'
99	'index'       '[enable index mode]'
100	'fullindex'   '[enable verbose index mode]'
101	'thumbnails'  '[enable interactive index mode]'
102	'menu-font'   '[set font in menus]:font: '
103	'no-menus'    "[don't load or show any menus]"
104	'reload-button' '[button to reload image]:button:_feh_button'
105	'pan-button'  '[button to pan image]:button:_feh_button'
106	'zoom-button' '[button to zoom image]:button:_feh_button'
107	'menu-button' '[button to activate menu]:button:_feh_button'
108	'prev-button' '[button to go to previous image]:button:_feh_button'
109	'next-button' '[button to go to next image]:button:_feh_button'
110	'rotate-button' '[Ctrl+Button to rotate image]:button:_feh_button'
111	'blur-button' '[Ctrl+Button tu blur image]:button:_feh_button'
112	'ignore-aspect' "[montage mode: Don't preserve aspect ratio]"
113	'stretch'     '[montage mode: Enlarge images to fit thumbnail size]'
114	'thumb-width' '[montage mode: Thumbnail width]:pixels: '
115	'thumb-height' '[montage mode: Thumbnail height]:pixels: '
116	'limit-width' '[montage mode: Limit montage width]:pixels: '
117	'limit-height' '[montage mode: Limit montage heihgt]:pixels: '
118	'bg'          '[montage mode: Background image]:file:_files'
119	'alpha'       '[montage mode: Thumbnail transparency level]:integer: '
120	'font'        '[index mode: Thumbnail info font]:font: '
121	'slideshow-delay' '[slide change delay]:seconds'
122	'scale-down'  '[scale down images which are too big]'
123	'output-dir'  '[save files to DIR (with -k)]:directory:_files -/'
124	'wget-timestamp' '[add no timestamp ("?123") to URLs]'
125	'fontpath'    '[add paths to font path]:font path:_files -/'
126	'image-bg'    '[set transparent image background]:background:(white black default)'
127	'output'      '[montage mode: Output file]:file:_files'
128	'output-only' "[montage mode: Output file, don't display montage]:file: files"
129	'rcfile'      '[specify config file]:file:_files'
130	'thumb-title' '[window title in thumbnail mode]:format string'
131	'title'       '[window title in slideshow mode]:format string'
132	'start-at'    '[start slideshow at]:file:_files'
133	'title-font'  '[title font for index mode]:font'
134)
135
136arguments=(
137	'--zoom[zoom images]:percent: '
138	'--caption-path[where to look for image captions]:relative directory: '
139	--action{1..9}':shell: '
140	'--bg-tile[set tiled desktop background]:file:_files'
141	'--bg-center[set centered desktop background]:file:_files'
142	'--bg-scale[set scaled desktop background]:file:_files'
143	'--bg-seamless[set desktop background with seamless borders]:file:_files'
144	'--bg-fill[set scaled desktop background, preserving aspect ratio]:file:_files'
145	'--menu-style[style descriptor for menu text]:file:_files'
146	'--menu-border[set menu background border]:integer: '
147	'--menu-ctrl-mask[use Ctrl+Button to display menu]'
148	'--no-rotate-ctrl-mask[don'\''t require Ctrl for the rotate button]'
149	'--no-blur-ctrl-mask[don'\''t require Ctrl for the blur button]'
150	'--no-xinerama[disable xinerama support]'
151	'--screen-clip[toggle window clipping]'
152	'--hide-pointer[hide mouse pointer in fullscreen mode]'
153	'*--fontpath[index mode: directory to search for fonts]:directory:_path_files -/'
154	'--index-name[show image name in index/thumbnail mode]:bool:(0 1)'
155	'--index-size[show image size in index/thumbnail mode]:bool:(0 1)'
156	'--index-dim[show image dimensions in index/thumbnail mode]:bool:(0 1)'
157	'--no-jump-on-resort[stay at current image after resorting the filelist]'
158	'--cycle-once[quit after one loop through the slideshow]'
159	'--draw-actions[draw defined actions]'
160	'--cache-thumbnails[enable thumbnail caching]'
161	'--menu-bg[background image in menus]: :_feh_background'
162	'--thumb-redraw[set thumbnail image redraw frequency]:digit'
163	'*:file:_files'
164)
165
166for arg in ${(k)argument_pairs}; {
167	arguments+='(--'${arg}')-'${argument_pairs[$arg]}${argument_postfix[$arg]}
168 	arguments+='(-'${argument_pairs[$arg]}[1]')--'${arg}${argument_postfix[$arg]}
169}
170
171function _feh_theme {
172	if [[ -r ~/.fehrc ]]; then
173		typeset -a themes tmp
174		typeset theme IFS=$'\n'
175		for theme in $(grep "\w" ~/.fehrc | grep -v "^#"); do
176			tmp=(${(s: :)theme})
177			theme=${tmp[1]}
178			shift tmp
179			themes+=${theme}:${(j: :)tmp}
180		done
181		_describe 'theme' themes
182	fi
183}
184
185function _feh_button {
186	typeset expl
187	_wanted button expl button \
188	compadd {0..5}
189}
190
191function _feh_background {
192	_alternative \
193	'file:file:_files' \
194	'mode:mode:(trans)'
195}
196
197_arguments -s ${arguments}
198