Lately, one suggestion was made to make menus reload when modified. The
solution to reload it everytime was simple but effectivly a little bit
annoying (I guess because all icons are reload). Well, on my DX/2 with
16m ram, it works fine. Anyway, I have investigated the possibility to
make this smarter, using the functionnality already available in fvwm2.
I must say the fvwm has a very nice look. I have recently introduce it to
few new coworker with no experience in Unix and X (All new programmer at
the office get a linux powered X terminal, yeh!). Most new user don't
need much to play with fvwm configuration, except at least adding items
to menus.
I have toyed with the idea above and came with this little setup.
-I have one file per menus
-Menus can be assembled on the fly using directory content.
-Menu file can be inherited from a system directory or override locally
by the user. Overriding the complete .fvwmrc setup is not fun.
Here is my button bar configuration. The key to it is the fixmenu
function. Not also that I place all fvwm2 configuration into a
subdirectory .fvwmdir. For readability, I have skip some configuration
line which are irrelevant here.
When poping a menu, I am calling the reread script which decide if the
menus must be reload or not. It produces a file .fvwmdir/tmp/menus.temp
and that file is always Read.
I am pretty happy about the result, except for one thing that I don't
understand. There is something weird in the function "fixmenu". Mostly
the first time I click on the modified menu, the old version shows up. It
only appears right the second time. It looks like all three line are
executed at once. I guess it is a side effect of the Exec command.
I am looking forward to install such a scheme at the office, as it will
eliminate one things which make user unconfortable (doing a reload of
fvwm to activate a single menu change).
Comment are welcome!
------------------------------------------------------------
AddToFunc fixmenu
+ "I" Exec .fvwmdir/sh/reread $0
+ "I" Read .fvwmdir/tmp/menus.temp
+ "I" Menu $0 Nop
*FvwmButtons Apps xchess.xpm fixmenu user
*FvwmButtons Outils tools.xpm fixmenu Outils
*FvwmButtons Graphiques graphs.xpm fixmenu Graphs
*FvwmButtons(5x1) - whatever SwallowModule "FvwmPager" FvwmPager 0 0
*FvwmButtons(1x1) - whatever Swallow "xmailbox" xmailbox &
*FvwmButtons(1x1) - whatever Swallow "xload" xload &
----------------------------------------------------------
here is the "reread" script. This could be easily rewritten in C to make
it quicker.
-----------------------------------------------------------
#!/bin/sh
MENU=$1
TEMP=.fvwmdir/tmp/$MENU.loaded
# The following file will be read by fvwm right after this shell execute
ACTION=.fvwmdir/tmp/menus.temp
upd_menufile()
{
FICH=$1
echo >$ACTION
if ! cmp -s $FICH $TEMP ; then
if [ -f $TEMP ] ; then
echo DestroyMenu $MENU >>$ACTION
fi
cp $FICH $TEMP
echo >>$ACTION
cat $FICH >>$ACTION
fi
}
upd_menudir()
{
DIR=$1
BUILD=$TEMP.build
echo AddToMenu $MENU $MENU Title >$BUILD
for i in `(cd $DIR; ls)`
do
if [ -x $DIR/$i ] ; then
echo + \"\" Nop >>$BUILD
if [ -f /usr/lib/X11/icons/$i.xpm ] ; then
echo + $i\%$i.xpm exec $DIR/$i >>$BUILD
elif [ -f $DIR/$i.xpm ] ; then
echo + $i\%$DIR/$i.xpm exec $DIR/$i >>$BUILD
else
echo + $i\%tools.xpm exec $DIR/$i >>$BUILD
fi
fi
done
echo >$ACTION
if ! cmp -s $BUILD $TEMP ; then
if [ -f $TEMP ] ; then
echo DestroyMenu \"$MENU\" >>$ACTION
fi
mv $BUILD $TEMP
echo >>$ACTION
cat $TEMP >>$ACTION
fi
}
if [ -f .fvwmdir/menus/$MENU ] ; then
upd_menufile .fvwmdir/menus/$MENU
elif [ -f /usr/lib/X11/fvwm2/menus/$MENU ] ; then
upd_menufile /usr/lib/X11/fvwm2/menus/$MENU
elif [ -d .fvwmdir/menus/$MENU ] ; then
upd_menudir .fvwmdir/menus/$MENU
elif [ -d /usr/lib/X11/fvwm2/menus/$MENU ] ; then
upd_menudir /usr/lib/X11/fvwm2/menus/$MENU
fi
-------------------------------------------------
Here is a sample .fvwmdir/menus/Graphs
-------------------------------------------------
AddToMenu Graphs "Graphiques" Title
+ "" Nop
+ "Wingz*sports/vikings1" Exec .fvwmdir/sh/wingz &
+ "" Nop
+ "XMag*magnifying_glass2.xpm" Exec xmag &
+ "" Nop
+ "Xv*xv.xpm" Exec xv &
+ "" Nop
+ "xplaycd*batsignal" Exec /usr/local/bin/xplaycd &
+ "" Nop
+ "xmixer*cdrom_look" Exec /usr/local/bin/xmixer &
--------------------------------------------------------
Jacques Gelinas (jacques_at_solucorp.qc.ca)
Use Linux without reformating: Use UMSDOS.
--
Visit the official FVWM web page at <URL:http://www.hpc.uh.edu/fvwm/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_hpc.uh.edu.
To report problems, send mail to fvwm-owner_at_hpc.uh.edu.
Received on Sun Apr 14 1996 - 21:28:50 BST