3 # Copyright © 2008, 2017 Nick Bowler
5 # Generates an FVWM menu for selecting the PNG images found in a given
6 # directory. Thumbnails for the images are generated on the fly using
7 # the thumbnailer.zsh script. Menu items run the specified function
8 # with the filename as the first argument.
10 thumber="$FVWM_USERDIR/scripts/thumbnail.zsh --size x160"
11 xaspect=$FVWM_USERDIR/scripts/C/xaspect
18 if test ${lastarg:+y}; then
24 --menu=*) menu=${arg#--menu=} ;;
25 --func=*) func=${arg#--func=} ;;
26 --menu|--func) lastarg=$arg ;;
28 -*) printf '%s: unrecognized argument: %s\n' "$0" "$arg" 1>&2; exit 1 ;;
29 *) set x "$@" "$arg"; shift
37 *) printf 'usage: %s [options] directory\n' "$0" 1>&2
40 size=`$xaspect -dimensions`
41 find $1 -maxdepth 1 -name "*$size.png" -print0 -exec $thumber {} \; |
43 gsub(/["\\]/, "\\\\&");
44 caption = gensub(/.*\/(.*)\..*/, "\\1", 1, $1);
45 print "AddToMenu", menuname, "\"" caption "*" $2 "*\"",
46 funcname, "\"" $1 "\""
47 }' "menuname=$menu" "funcname=$func"