James Griffin <[email protected]> writes:
> Hi
>
> I have used an example for creating a dynamic menu to view pictures,
> found on the fvwm site to create a documents menu.
>
> The problem I have is -- in both examples really -- the files in these
> directories are likely to different types. So, using the pictures example
> on the fvwm site, it shows how to create the menu for files of .jpg type.
>
> I would like to extend it show all the files, i.e. not just
> jpg files, but to use a different program to view different file types.
>
> to make this clearer, here is the function is question for the pictures
> menu shown on the fvwm site:
>
> AddToMenu JpgMenu Pictures title
> + MissingSubmenuFunction FuncFvwmMenuDirectory
> + DynamicPopupAction Function MakeJpgMenu
>
> AddToFunc MakeJpgMenu
> + I DestroyMenu recreate JpgMenu
> + I AddToMenu JpgMenu Pictures Title
> + I PipeRead 'for i in $HOME/pictures/*.jpg; \
> do echo AddToMenu JpgMenu "`basename $i`" Exec xv $i; done'
>
> As it happens, xv can open all of the image types i'm likely to ever have
> in that directory, so I can alter it to list all files by replacing
> '*.jpg' with '*.*'
> I "think" it would need a shell case statement, perhaps? Although i'm not
> certain about that and also not confident enough to write it.
>
> Would someone mind showing me how I could do this? Perhaps to provide an
> example?
Try replacing '*.jpg' with just '*'.
*.* is from Windows .BAT files.
When referring to $i, always include quotes like this:
do echo AddToMenu JpgMenu "`basename "$i"`" Exec xv "$i"; done'
(You need the quotes to handle file names with spaces.)
Instead of 'Exec xv' do:
Exec exec my-handle-file.
Where "my-handle-file" is a shell you write that figures out what
program to execute.
In my-handle-file figure out what to execute based on $1:
case "$1" in
*.jpg) exec xv $1;;
*.doc) exec ooffice $1;;
*) echo "say what";;
esac
--
Dan Espen