From c8a11a2de6e19926eaff6d6c725fd6a3a55e2c0b Mon Sep 17 00:00:00 2001 From: Krzysztof Mrozowicz Date: Mon, 14 Aug 2023 09:09:50 +0000 Subject: [PATCH] - up to 3.10 - added zsh-completion - refreshed bash-completion --- feh-bash-completion | 143 ++++++++++++++++++++++++++++++++++---------- feh-zsh-completion | 128 +++++++++++++++++++++++++++++++++++++++ feh.spec | 74 +++++++++++++++++------ 3 files changed, 297 insertions(+), 48 deletions(-) create mode 100644 feh-zsh-completion diff --git a/feh-bash-completion b/feh-bash-completion index 78c781c..5ba9751 100644 --- a/feh-bash-completion +++ b/feh-bash-completion @@ -1,35 +1,118 @@ -# feh bash_completition - made by uzsolt -# TODO: add more file extensions +# bash completion for feh(1) -*- shell-script -*- -_feh() +_comp_cmd_feh() { - local cur + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return - COMPREPLY=() - cur=${COMP_WORDS[COMP_CWORD]} + local noargopts='!(-*|*[foO|KCjeM@TSRHWEyJabgLD~^]*)' + # shellcheck disable=SC2254 + case "$prev" in + --image-bg | -B) + _comp_compgen -- -W 'checks white black' + return + ;; + --filelist | --output | --output-only | --start-at | -${noargopts}[foO\|]) + _comp_compgen_filedir + return + ;; + --caption-path | --fontpath | --output-dir | -${noargopts}[KCj]) + _comp_compgen_filedir -d + return + ;; + --font | --menu-font | --title-font | -${noargopts}[eM@]) + # expect string like "dejavu.ttf/12" + if [[ $cur == */* ]]; then # expect integer value + _comp_compgen -R -- -P "$cur" -W '{0..9}' + compopt -o nospace + return + fi + local font_path + # font_path="$(imlib2-config --prefix 2>/dev/null)/share/imlib2/data/fonts" + # _comp_compgen -C "$font_path" -- -f -X "!*.@([tT][tT][fF])" -S / + for ((i = ${#words[@]} - 1; i > 0; i--)); do + if [[ ${words[i]} == -@(C|-fontpath) ]]; then + font_path="${words[i + 1]}" + _comp_compgen -aC "$font_path" -- \ + -f -X "!*.@([tT][tT][fF])" -S / + fi + done + compopt -o nospace + return + ;; + --theme | -${noargopts}T) + local conf_path=~/.config/feh/themes + local theme_name theme_opts + [[ -r $conf_path ]] || return + while read -r theme_name theme_opts; do + if [[ $theme_name == '#'* || $theme_name == "" ]]; then + continue + fi + _comp_compgen -a -- -W "$theme_name" + done <"$conf_path" + return + ;; + --sort | -${noargopts}S) + _comp_compgen -- -W 'name filename mtime width height pixels size + format' + return + ;; + --reload | --limit-height | --limit-width | --thumb-height | --thumb-width | \ + --thumb-redraw | --magick-timeout | -${noargopts}[RHWEyJ]) + # expect integer value + _comp_compgen -aR -- -W '{0..9}' + compopt -o nospace + return + ;; + --zoom) + # expect integer value or "max", "fill" + _comp_compgen -- -W 'max fill' + if [[ ! $cur || ! ${COMPREPLY-} ]]; then + _comp_compgen -aR -- -W '{0..9}' + compopt -o nospace + fi + return + ;; + --alpha | -${noargopts}a) + _comp_compgen -- -W '{0..255}' + return + ;; + --bg | -${noargopts}b) + _comp_compgen_filedir + _comp_compgen -a -- -W 'trans' + return + ;; + --geometry | --max-dimension | --min-dimension | -${noargopts}g) + # expect string like 640x480 + if [[ $cur && $cur != *x* ]]; then + COMPREPLY=(x) + fi + _comp_compgen -aR -- -W "{0..9}" + compopt -o nospace + return + ;; + --customlist | --index-info | --info | --slideshow-delay | --thumb-title | \ + --title | -${noargopts}[LD~^]) + # argument required but no completions available + return + ;; + esac - case "$cur" in - -*) - COMPREPLY=( $( compgen -W ' -1 -2 -4 -5 -6 -7 -8 -9\ - -a -A --action1 --action2 --action3 --action4 --action5 --action6 --action7 --action8 --action9\ - --alpha --auto-zoom -b --bg --bg-center --bg-scale --bg-seamless --bg-tile --blur-button\ - --borderless --builtin -c --cache-thumbnails --caption-path --collage --customlist --cycle-once\ - -d -D --draw-filename -e -E -f -F --filelist --fontpath --fullindex --full-screen -g -G --geometry\ - -h -H --help --hide-pointer -i -I --ignore-aspect --index -j -k --keep-http -l -L --limit-height \ - --limit-width --list --loadable -m -M --menu-bg --menu-border --menu-button --menu-ctrl-mask \ - --menu-font --menu-style --montage --multiwindow -n -N --next-button --no-blur-ctrl-mask \ - --no-jump-on-resort --no-menus --no-rotate-ctrl-mask -o -O --output-dir -p --preload -q -Q \ - --quiet -r -R --randomize --rcfile --recursive --reload --reverse --rotate-button -s -S - --scale-down --screen-clip --slideshow-delay --sort --stretch -t -T --theme --thumb-height \ - --thumbnails --thumb-width --title --title-font -u -U --unloadable -v -V --verbose --version \ - -w -W --wget-timestamp -x -X --xinerama -y -z -Z --zoom --zoom-button' -- $cur ) ) - ;; - *) - _filedir '@(jpg|jpeg|png|gif|bmp|ppm|xpm|JPG|JPEG|PNG|GIF|BMP|PPM)' - ;; - esac - - return 0 + [[ $was_split ]] && return -} -complete -F _feh -o filenames feh + if [[ $cur == -* ]]; then + # Some versions of feh just output "See 'man feh'" for --help :( + _comp_compgen_help + if [[ ${COMPREPLY-} ]]; then + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + fi + + # FIXME: It is hard to determine correct supported extensions. + # feh can handle any format that imagemagick can plus some others + _comp_compgen_filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf|ff?(.gz|.bz2)|webp' +} && + complete -F _comp_cmd_feh feh + +# ex: filetype=sh diff --git a/feh-zsh-completion b/feh-zsh-completion new file mode 100644 index 0000000..a65437e --- /dev/null +++ b/feh-zsh-completion @@ -0,0 +1,128 @@ +#compdef feh +## completion for feh 3.0, based on feh(1) + +function _feh_theme { + [[ -r ~/.config/feh/themes ]] || return + typeset -a themes + typeset -i cont=0 + typeset cur_theme cur_desc + + while read theme_name theme_options; do + + if [[ ${theme_name} == '#'* ]] { + continue + } + + if (( ! ${#theme_name} && ! ${#theme_options} )) { + continue + } + + themes+="${theme_name}:${theme_options}" + + done < ~/.config/feh/themes + + _describe 'theme' themes +} + +function _feh_button { + typeset expl + _wanted button expl button \ + compadd {0..5} +} + +function _feh_background { + _alternative \ + 'file:file:_files' \ + 'mode:mode:(trans)' +} + +function _feh { + _arguments -s -S \ + '(--action -A)'{-A,--action}'[action to perform on images]:shell command:_cmdstring' \ + --action{1..9}'[additional action]:shell command:_cmdstring' \ + '--auto-rotate[automatically rotate images based on EXIF data]' \ + '(--auto-zoom -Z)'{-Z,--auto-zoom}'[zoom pictures to screen]' \ + '(--borderless -x)'{-x,--borderless}'[create borderless windows]' \ + '--cache-size[Imlib2 in-memory cache size]:cache size in MiB' \ + '(--cache-thumbnails -P)'{--cache-thumbnails,-P}'[cache thumbnails]' \ + '(--caption-path -K)'{--caption-path,-K+}'[enable caption mode]:caption directory:_files -/' \ + '--conversion-timeout[set ImageMagick conversion timeout for unlodable files]:timeout in seconds (-1 to disable)' \ + '(--customlist -L)'{--customlist,-L}'[custom list mode]:feh format string' \ + '(--draw-actions -G)'{--draw-actions,-G}'[show defined actions]' \ + '--draw-exif[show EXIF data]' \ + '(--draw-filename -d)'{--draw-filename,-d}'[show filename]' \ + '--draw-tinted[show overlay texts on tinted background]' \ + '--edit[change files in-place when using rotate and mirror keys]' \ + '(--filelist -f)'{--filelist,-f}'[load from/save to filelist]:filelist:_files' \ + '(--font -e)'{--font,-e+}'[set global font]:font' \ + '(--fontpath -C)'{--fontpath,-C+}'[set font path]:font path:_files -/' \ + '--force-aliasing[disable antialiasing]' \ + '(--fullindex -I)'{--fullindex,-I}'[index mode with additional information]' \ + '(--fullscreen -F)'{--fullscreen,-F}'[start in fullscreen mode]' \ + '(--geometry -g)'{--geometry,-g+}'[set window geometry]:WxH[+X+Y]' \ + '(--hide-pointer -Y)'{--hide-pointer,-Y}'[hide pointer]' \ + '(--image-bg -B)'{--image-bg,-B+}'[set image background]:background style or X11 colour:(default checks)' \ + '(--index -i)'{--index,-i}'[index mode]' \ + '--index-info[image info for thumbnail/index mode]:format string' \ + '--info[filo info command]:shell command:_cmdstring' \ + '--insecure[disable HTTPS certificate checks]' \ + '(--keep-http -k)'{--keep-http,-k}'[keep cached HTTP files]' \ + '--keep-zoom-vp[keep zoom and viewport when switching images]' \ + '(--list -l)'{--list,-l}'[list mode]' \ + '(--loadable -U)'{--loadable,-U}'[list loadable images]' \ + '--max-dimension[set maximum image dimensions]:WxH' \ + '(--menu-font -M)'{--menu-font,-M+}'[set menu font]:menu font' \ + '--min-dimension[set minimum image dimensions]:WxH' \ + '(--montage -m)'{--montage,-m}'[montage mode]' \ + '(--multiwindow -w)'{--multiwindow,-w}'[multiwindow mode]' \ + '--no-jump-on-resort[do not jump to first image after resorting]' \ + '(--no-menus -N)'{--no-menus,-N}'[disable menus]' \ + '--no-screen-clip[disable window size limits]' \ + '--no-xinerama[disable Xinerama support]' \ + '--on-last-slide[set behaviour when advancing past the last slide]:behaviour:(hold quit resume)' \ + '(--output-dir -j)'{--output-dir,-j+}'[set temporary file location]:directory:_files -/' \ + '(--preload -p)'{--preload,-p}'[eliminate unloadable images before starting]' \ + '(--quiet -q)'{--quiet,-q}'[do not report non-fatal errors]' \ + '(--randomize -z)'{--randomize,-z}'[randomize filelist]' \ + '(--recursive -r)'{--recursive,-r}'[recurse into subdirectories]' \ + '--no-recursive[do not recurse into subdirectories]' \ + '(--reload -R)'{--reload,-R+}'[regularly reload filelist and current image]:seconds' \ + '(--reverse -n)'{--reverse,-n}'[reverse sort order]' \ + '(--scale-down -.)'{--scale-down,-.}'[scale down too large images]' \ + '--scroll-step[set scroll granularity]:pixels per scroll step' \ + '(--slideshow-delay -D)'{--slideshow-delay,-D+}'[set slideshow delay]:seconds' \ + '(--sort -S)'{--sort,-S}'[sort images]:sort key:(name filename dirname mtime width height pixels size format)' \ + '(--start-at -|)'{--start-at,-'|'+}'[start slideshow at file]:start file:_files' \ + '(--theme -T)'{--theme,-T+}'[set theme]: :_feh_theme' \ + '(--thumbnails -t)'{--thumbnails,-t}'[thumbnail mode]' \ + '(--thumb-title -~)'{--thumb-title,-'~'+}'[set thumbnail window title]:feh format string' \ + '(--title -^)'{--title,-'^'}'[set window title]:feh format string' \ + '(--unloadable -u)'{--unloadable,-u}'[list unloadable images]' \ + '(--verbose -V)'{--verbose,-V}'[verbose mode]' \ + '--version-sort[use natural sorting for --sort]' \ + '--zoom[set default zoom level]:percent' \ + \ + '(--alpha -a)'{--alpha,-a}'[set thumbnail transparency]:alpha level' \ + '(--bg -b)'{--bg,-b}'[set montage background]: :_feh_background' \ + '(--ignore-aspect -X)'{--ignore-aspect,-X}'[ignore aspect in montage mode]' \ + '(--limit-height -H)'{--limit-height,-H}'[limit montage height]:pixels' \ + '(--limit-width -W)'{--limit-width,-W}'[limit montage width]:pixels' \ + '(--output -o)'{--output,-o}'[save created montage]:output file:_files' \ + '(--output-only -O)'{--output-only,-O}'[only save created montage]:output file:_files' \ + '(--stretch -s)'{--stretch,-s}'[enlarge too small images in montage mode]' \ + '(--thumb-height -E)'{--thumb-height,-E}'[set montage mode thumbnail height]:pixels' \ + '(--thumb-width -y)'{--thumb-width,-y}'[set montage mode thumbnail width]:pixels' \ + '(--thumb-redraw -J)'{--thumb-redraw,-J}'[set thumbnail mode redraw interval]:interval' \ + \ + '--bg-center[set centered background]' \ + '--bg-fill[set filled background (zoom until filled)]' \ + '--bg-max[set maxed background (zoom until image fits)]' \ + '--bg-scale[set background without preserving aspect ratio]' \ + '--bg-tile[set tiled background]' \ + \ + '(--title-font -@)'{--title-font,-'@'}'[set title font]:font' \ + '*:image, directory or URL:_files' +} + +_feh "$@" + diff --git a/feh.spec b/feh.spec index 1ecab4f..36632ef 100644 --- a/feh.spec +++ b/feh.spec @@ -2,22 +2,29 @@ Summary: Fast image viewer/indexer/montager Summary(hu.UTF-8): Gyors képnézegető/indexelő/montázsoló Summary(pl.UTF-8): Szybki program do przeglądania/indeksowania/montowania obrazów Name: feh -Version: 2.5 -Release: 3 +Version: 3.10 +Release: 1 License: BSD Group: X11/Applications/Graphics -Source0: https://derf.homelinux.org/~derf/projects/feh/%{name}-%{version}.tar.bz2 -# Source0-md5: d5f6048f79005c05b51060beafd1f08d -URL: http://feh.finalrewind.org/ -# Patch0: %{name}-install.patch +Source0: https://feh.finalrewind.org/%{name}-%{version}.tar.bz2 +# Source0-md5: 8adf6db9c5b18816df5ce539244d2329 +URL: https://feh.finalrewind.org/ +# Bash completion by https://github.com/scop/bash-completion/blob/master/completions/feh Source1: %{name}-bash-completion -BuildRequires: giblib-devel >= 1.2.4 +# zsh completion by https://git.finalrewind.org/zsh/plain/etc/completions/_feh +Source2: %{name}-zsh-completion +BuildRequires: curl-devel BuildRequires: imlib2-devel >= 1.0.0 +BuildRequires: libexif-devel BuildRequires: libjpeg-devel +BuildRequires: libmagic-devel BuildRequires: libpng-devel BuildRequires: sed >= 4.0 +BuildRequires: xorg-lib-libX11-devel BuildRequires: xorg-lib-libXinerama-devel BuildRequires: xorg-lib-libXt-devel +Requires: ImageMagick +Requires: imlib2_loaders Provides: WallpaperChanger BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) @@ -50,51 +57,82 @@ rekursywne otwieranie plików (pokaz slajdów z hierarchii katalogów), oraz sterowanie z klawiatury/myszki (też z kółkiem). %package -n bash-completion-feh -Summary: bash-completion to feh -Summary(pl.UTF-8): bashowe dopełnianie linii poleceń programu feh +Summary: Bash completion for feh +Summary(pl.UTF-8): Dopełnianie parametrów feh dla powłoki Bash Group: Applications/Shells -Requires: bash-completion +Requires: bash-completion >= 1:2.0 +Requires: %{name} = %{version}-%{release} Obsoletes: feh-bash-completion BuildArch: noarch %description -n bash-completion-feh -bash-completion to feh. +Bash completion for feh. %description -n bash-completion-feh -l pl.UTF-8 -bashowe dopełnianie linii poleceń programu feh. +Dopełnianie parametrów feh dla powłoki Bash. + +%package -n zsh-completion-feh +Summary: ZSH completion for feh +Summary(pl.UTF-8): Dopełnianie parametrów feh dla powłoki ZSH +Group: Applications/Shells +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description -n zsh-completion-feh +ZSH completion for feh. + +%description -n zsh-completion-feh -l pl.UTF-8 +Dopełnianie parametrów feh dla powłoki ZSH. %prep %setup -q -# %patch0 -p1 -%{__sed} -i "s|CFLAGS ?=.*|CFLAGS = %{rpmcflags}|" config.mk %build %{__make} \ - CC="%{__cc}" \ - PREFIX=%{_prefix} + PREFIX=%{_prefix} \ + help=1 \ + inotify=1 \ + exif=1 %install rm -rf $RPM_BUILD_ROOT install -d $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d +install -d $RPM_BUILD_ROOT%{zsh_compdir} %{__make} install \ DESTDIR=$RPM_BUILD_ROOT \ PREFIX=%{_prefix} -install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/%{name} +cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/%{name} +cp -p %{SOURCE2} $RPM_BUILD_ROOT%{zsh_compdir}/_%{name} %{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name} %clean rm -rf $RPM_BUILD_ROOT +%post +%update_icon_cache hicolor +%update_desktop_database + +%postun +%update_icon_cache hicolor +%update_desktop_database + %files %defattr(644,root,root,755) -%doc AUTHORS COPYING ChangeLog examples README TODO +%doc AUTHORS COPYING ChangeLog examples README.md TODO %attr(755,root,root) %{_bindir}/* %{_datadir}/feh %{_mandir}/man1/*.1* +%{_desktopdir}/feh.desktop +%{_iconsdir}/hicolor/48x48/apps/feh.png +%{_iconsdir}/hicolor/scalable/apps/feh.svg %files -n bash-completion-feh %defattr(644,root,root,755) %{_sysconfdir}/bash_completion.d/%{name} + +%files -n zsh-completion-feh +%defattr(644,root,root,755) +%{zsh_compdir}/_feh -- 2.44.0