Discussion:
FVWM: Help with building dynamic menus
James Griffin
2013-08-25 10:02:25 UTC
Permalink
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 '*.*'

following this example, with my document directory, I will most likely
have pdf, doc, docx (OpenOffice stuff), text files, ... etc. So for each
type I will need a different program to be executed in order to view
and/or edit them.

How can I extend the function to map different file types to their
respective programs? Naturally, xpdf for pdf's; OpenOffice for .doc[x];
emacs or vi for text files.

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?

Many thanks.

Jamie.
--
James Griffin: jmz at kontrol.kode5.net

A4B9 E875 A18C 6E11 F46D B788 BEE6 1251 1D31 DC38
Loading...