Appy FvwmIconMan sticyicon fix.
[fvwm.git] / utils / fvwm_make_directory_menu.sh
blobe5e056a9de7665532cc42f7a2061dfa0699fe5a6
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'`
46 PMENU=`echo "$MENU" | $SED -e s:\"::g`
48 # the command to execute on plain files
49 ACTION=vi
51 # the terminal program to invoke
52 TERMINAL="xterm -e"
53 TERMINALSHELL="xterm"
56 # you may customize this script below here.
59 # dump all menu items
60 echo DestroyMenu recreate \""$PMENU"\"
62 # add a new title
63 echo AddToMenu \""$PMENU"\" \""$PMENU"\" Exec "echo cd $MENU\; $TERMINALSHELL | $SHELL"
65 # add a separator
66 echo AddToMenu \""$PMENU"\" \"\" nop
68 # destroy the menu after it is popped down
69 if [ "$OPTIMIZE_SPACE" = yes ] ; then
70 echo AddToMenu \""$PMENU"\" DynamicPopDownAction DestroyMenu \""$PMENU"\"
73 # set the 'missing submenu function'
74 echo AddToMenu \""$PMENU"\" MissingSubmenuFunction MakeMissingDirectoryMenu
76 # add directory contents
77 $LS "$MENU" 2> /dev/null | $SED -n '
78 /\/$/ bdirectory
79 s:[=*@|]$::1
80 s:"::g
81 s:^\(.*\)$:AddToMenu "'"$PMENU"'" "\1" Exec '"$TERMINAL $ACTION"' "'"$MENU"'/\1":1
82 bnext
83 :directory
84 s:^\(.*\)/$:AddToMenu "'"$PMENU"'" "\1" Popup "'"$PMENU"'/\1" item +100 c:1
85 :next
86 s://*:/:g