* fvwm/fvwm2.1: Fixes to the font section
[fvwm.git] / utils / fvwm_make_directory_menu.sh
blobbb36f5b665aa90e75f0f6c913ddee78fb1f746d5
1 #!/bin/sh
3 ###
4 # This script demonstates the fvwm menu MissingSubmenuFunction functionality.
5 # You can use a more configurable fvwm-menu-directory instead.
6 # The line below almost exactly simulates this script:
7 # fvwm-menu-directory --links --order 4 --exec-file vi --dir DIR
8 ###
10 # Modification History
12 # Created on 06/07/99 by Dominik Vogt (domivogt):
14 # provides output to read in with PipeRead to build a menu
15 # containing a directory listing.
17 # You should put these lines into your fvwm configuration file to invoke
18 # this script:
20 # AddToFunc MakeMissingDirectoryMenu
21 # + i piperead 'fvwm_make_directory_menu.sh '$0
23 # And put these lines in the menu from which you want to pop up the
24 # directory menus:
26 # AddToMenu SomeMenu MissingSubmenuFunction MakeMissingDirectoryMenu
27 # + "my directory item" Popup /whatever/path/you/like
29 # Note: please use absolute path names.
32 # configuration section
35 # If you want to optimize for speed, unset this variable. Warning: speed
36 # optimization takes up a lot of memory that is never free'd again while fvwm
37 # is running.
38 OPTIMIZE_SPACE=yes
40 # you may use the absolute path here if you have an alias like ls="ls -F"
41 LS="/bin/ls -LF"
42 SED=sed
44 # the name of our menu
45 MENU=`echo $1 | $SED -e 's://*:/:g'`
47 # the item title
48 ITEM='basename $MENU'
50 # the command to execute on plain files
51 ACTION=vi
53 # the terminal program to invoke
54 TERMINAL="xterm -e"
55 TERMINALSHELL="xterm"
58 # you may customize this script below here.
61 # dump all menu items
62 echo DestroyMenu recreate \"$MENU\"
64 # add a new title
65 echo AddToMenu \"$MENU\" \"$MENU\" Exec "echo cd $MENU\; $TERMINALSHELL | $SHELL"
67 # add a separator
68 echo AddToMenu \"$MENU\" \"\" nop
70 # destroy the menu after it is popped down
71 if [ "$OPTIMIZE_SPACE" = yes ] ; then
72 echo AddToMenu \"$MENU\" DynamicPopDownAction DestroyMenu \"$MENU\"
75 # set the 'missing submenu function'
76 echo AddToMenu \"$MENU\" MissingSubmenuFunction MakeMissingDirectoryMenu
78 # add directory contents
79 $LS "$MENU" 2> /dev/null | $SED -n '
80 /\/$/ bdirectory
81 s:[=*@|]$::1
82 s:^\(.*\)$:AddToMenu "'$MENU'" "\1" Exec '"$TERMINAL $ACTION"' "'"$MENU"'/\1":1
83 bnext
84 :directory
85 s:^\(.*\)/$:AddToMenu "'$MENU'" "\1" Popup "'"$MENU"'/\1" item +100 c:1
86 :next
87 s://*:/:g