3 # Adds installed applications to the box-stock system.vtwmrc file.
7 # could be a "here-doc", but it'd break at least one shell
9 echo "Usage: ${0##*/} [-i in_file] [-o out_file] [-m menu_decl] \\"
10 echo " [-a app_list | -A app_file] [-f] [-h]"
12 echo "Default in_file: $DEF_INPUT"
13 echo "Default out_file: $DEF_OUTPUT"
14 echo "Default menu_decl: $DEF_MENU_DECL"
15 echo "Default app_list: $DEF_LIST"
17 echo "app_file is a list, each line containing one application specification"
18 echo "(or the keywords \"SEPARATOR\" or \"TITLE::string\"). The specification is"
19 echo "of the form \"name::string\", where \"name\" is the menu entry and \"string\""
20 echo "is the command to execute. Whitespace in either part is indicated with"
21 echo "a single colon."
30 cd `dirname "$INPUT"` && INDIR=$PWD && INNAME=`basename "$INPUT"`
31 cd `dirname "$OUTPUT"` && OUTDIR=$PWD && OUTNAME=`basename "$OUTPUT"`
33 if [ "$INDIR" = "$OUTDIR" -a "$INNAME" = "$OUTNAME" ]; then
34 if [ $NO_PROMPT -eq 1 ]; then
35 echo "Replacing in_file with out_file."
37 echo -n "Replace in_file with out_file (y/n)? "
39 [ "$ANS" != "y" -a "$ANS" != "Y" ] && \
40 echo "Exiting." && exit
49 ANS=`which xterm 2>/dev/null`
50 if [ -z "$ANS" ]; then
51 if [ $NO_PROMPT -eq 1 ]; then
52 echo "No path to X applications (xterm)."
54 echo "The path to X applications (xterm) isn't set."
56 echo -n "Enter full X path: "
58 [ -z "$ANS" ] && echo "Exiting." && exit
59 [ -d "$ANS" -a -f "$ANS/xterm" -a \
60 -x "$ANS/xterm" ] && break
70 echo "in_file: $INPUT"
71 if [ "$OUTPUT" = "$TMPOUT" ]; then
72 echo "out_file: $INPUT"
74 echo "out_file: $OUTPUT"
76 echo "menu_decl: $MENU_DECL"
77 echo "app_list: $APP_LIST"
78 echo "app_file: $APP_FILE"
79 echo "Search path: $PATH"
81 if [ $NO_PROMPT -eq 1 ]; then
84 echo -n "Proceed (y/n)? "
86 [ "$ANS" != "y" -a "$ANS" != "Y" ] && echo "Exiting." && exit
92 if [ "$1" = "SEPARATOR" ]; then
93 printf "\t\"\"\t\tf.separator\n" >>$2
98 if [ "$CMD" = "TITLE" ]; then
99 printf "\t\" %s \"\t\tf.title\n" $STR \
100 |sed -e 's/:/ /g' >>$2
102 [ -z "`which $CMD 2>/dev/null`" ] && return
103 printf "\t\"%s\"\t\tf.exec \"%s &\"\n" $CMD $STR \
104 |sed -e 's/:/ /g' >>$2
109 DEF_INPUT=./system.vtwmrc
110 DEF_OUTPUT=./custom.vtwmrc
112 DEF_LIST="TITLE::Shells emu eterm mxterm rxvt xterm xvt"
113 DEF_LIST="$DEF_LIST midc::xterm:-e:midc top::xterm:-e:top"
114 DEF_LIST="$DEF_LIST TITLE::Editors nedit xcoral xvile"
115 DEF_LIST="$DEF_LIST vi::xterm:-e:vi vile::xterm:-e:vile vim::xterm:-e:vim"
116 DEF_LIST="$DEF_LIST SEPARATOR gimp xfig xpaint xv xbmbrowser bitmap pixmap"
117 DEF_LIST="$DEF_LIST TITLE::Desktop applix soffice abiword lyx ted::Ted"
118 DEF_LIST="$DEF_LIST gnumeric ghostview gv xcal xcalendar"
119 DEF_LIST="$DEF_LIST SEPARATOR tkman xman"
120 DEF_LIST="$DEF_LIST SEPARATOR gmplayer xine xmcd xmmix xmms"
121 DEF_LIST="$DEF_LIST SEPARATOR hexcalc xcalc editres"
122 DEF_LIST="$DEF_LIST xbiff xcb xev xeyes xload xmag"
123 DEF_LIST="$DEF_LIST SEPARATOR moonclock mouseclock oclock"
124 DEF_LIST="$DEF_LIST rclock sunclock t3d xarclock xclock xdaliclock"
125 DEF_LIST="$DEF_LIST TITLE::Network chimera ie mozilla netscape opera"
126 DEF_LIST="$DEF_LIST links::xterm:-e:links lynx::xterm:-e:lynx"
127 DEF_LIST="$DEF_LIST SEPARATOR exmh knews xdir"
128 DEF_LIST="$DEF_LIST ftp::xterm:-e:ftp telnet::xterm:-e:telnet"
129 DEF_LIST="$DEF_LIST elm::xterm:-e:elm mutt::xterm:-e:mutt"
130 DEF_LIST="$DEF_LIST pine::xterm:-e:pine tin::xterm:-e:tin"
132 DEF_MENU_DECL="menu \"apps\""
139 while getopts "i:o:m:a:A:fh" OPT; do
143 m) MENU_DECL=$OPTARG;;
144 a) APP_LIST=$OPTARG;;
145 A) APP_FILE=$OPTARG;;
151 [ -z "$INPUT" ] && INPUT=$DEF_INPUT
152 [ -z "$OUTPUT" ] && OUTPUT=$DEF_OUTPUT
153 [ -z "$APP_LIST" ] && APP_LIST=$DEF_LIST
154 [ -n "$APP_FILE" ] && APP_LIST=
155 [ -z "$MENU_DECL" ] && MENU_DECL=$DEF_MENU_DECL
157 [ ! -f "$INPUT" ] && echo "$INPUT: File not found" && syntax
163 if [ -n "$APP_LIST" ]; then
164 for APP in $APP_LIST; do
165 check_app $APP $LISTOUT
168 if [ -f "$APP_FILE" ]; then
170 check_app $APP $LISTOUT
173 echo "$APP_FILE: File not found"
178 [ ! -s $LISTOUT ] && echo "No applications added." && exit
184 |awk -v list="$LISTOUT" -v menu="$MENU_DECL" \
188 if ($1 == menu[1] && $2 == menu[2]) { \
191 if ($1 == "{") print "{"; \
193 } while (a && $1 != "}"); \
194 if (a && $1 == "}") { \
195 while (getline app <list) \
204 [ -s $TMPOUT ] && mv $TMPOUT "$INPUT"