Played with menu generation scripts to

1. Speed them up - seems to be about a 300% speedup
2. Make them safe when arguments and fields in desktop files have spaces


SVN revision: 3516
This commit is contained in:
Horms 2000-09-17 22:27:04 +00:00
parent 08fe63445a
commit 0b7805db77
3 changed files with 329 additions and 257 deletions

View File

@ -30,86 +30,124 @@ if [ $# -lt 3 ]; then
echo " "$0" base_name output_dir output_file.menu [gnome_app_base_dir]" echo " "$0" base_name output_dir output_file.menu [gnome_app_base_dir]"
exit exit
fi fi
# setup variables
BASE=$1
ODIR=$2
OUT=$3
# setup variables
BASE="$1"
ODIR="$2"
OUT="$3"
CONVERT_CMD="`which convert`"
# NEW # NEW
find_app_base_dir() { find_app_base_dir() {
ADIR=`gnome-config --prefix`"/share/gnome/apps" ADIR="`gnome-config --prefix`/share/gnome/apps"
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/share/gnome/apps ADIR="/usr/share/gnome/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/share/apps ADIR="/usr/share/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/local/share/apps ADIR="/usr/local/share/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/gnome/share/apps ADIR="/usr/gnome/share/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/local/gnome/share/apps ADIR="/usr/local/gnome/share/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/opt/gnome/share/apps ADIR="/opt/gnome/share/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/opt/gnome/share/gnome/apps ADIR="/opt/gnome/share/gnome/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/usr/X11R6/share/gnome/apps ADIR="/usr/X11R6/share/gnome/apps"
else
return
fi fi
if [ ! -d "$ADIR" ]; then if [ ! -d "$ADIR" ]; then
ADIR=/opt/local/share/apps ADIR="/opt/local/share/apps"
else
return
fi fi
} }
find_icon_base_dir() { find_icon_base_dir() {
IDIR=`gnome-config --prefix`"/share/pixmaps" IDIR="`gnome-config --prefix`/share/pixmaps"
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/share/pixmaps IDIR="/usr/share/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/share/gnome/pixmaps IDIR="/usr/share/gnome/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/local/share/pixmaps IDIR="/usr/local/share/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/gnome/share/pixmaps IDIR="/usr/gnome/share/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/local/gnome/share/pixmaps IDIR="/usr/local/gnome/share/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/opt/gnome/share/pixmaps IDIR="/opt/gnome/share/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/opt/gnome/share/gnome/pixmaps IDIR="/opt/gnome/share/gnome/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/usr/X11R6/share/gnome/pixmaps IDIR="/usr/X11R6/share/gnome/pixmaps"
else
return
fi fi
if [ ! -f $IDIR"/gnome-help.png" ]; then if [ ! -f "${IDIR}/gnome-help.png" ]; then
IDIR=/opt/local/share/pixmaps IDIR="/opt/local/share/pixmaps"
else
return
fi fi
} }
if [ $# -eq 4 ]; then if [ $# -eq 4 ]; then
DIR=$4 DIR="$4"
else else
find_app_base_dir find_app_base_dir
DIR=$ADIR DIR="$ADIR"
fi fi
# In most cases I believe the icons can be found in the directory that is # In most cases I believe the icons can be found in the directory that is
# ../../pixmaps from $ADIR. # ../../pixmaps from $ADIR.
find_icon_base_dir find_icon_base_dir
GICONDIR=$IDIR GICONDIR="$IDIR"
# if the apps dir doesn't exist in the end then exit # if the apps dir doesn't exist in the end then exit
if [ ! -d "$DIR" ]; then if [ ! -d "$DIR" ]; then
@ -117,100 +155,87 @@ if [ ! -d "$DIR" ]; then
fi fi
# if the destination dir doesnt exist - create it # if the destination dir doesnt exist - create it
if [ ! -d "$ODIR" ]; then if [ ! -d "$ODIR" ]; then
mkdir $ODIR mkdir "$ODIR"
fi fi
# function to check its a GNOME desktop file # function to check its a GNOME desktop file
is_desktop() { is_desktop() {
VAL=`grep "\[Desktop Entry\]" $1` VAL="`grep "\[Desktop Entry\]" $1`"
if [ -n "$VAL" ]; then if [ -n "$VAL" ]; then
VAL=`grep "^Name\[$LANG\]=" $1 | head -1` IS_DESKTOP_RESULT="`awk -F= 'BEGIN { n="" } END { printf("%s", n) } $1 ~ "^Name\\\['$LANG'\\\]" {n=$2;exit} $1 ~ "^Name$" {n=$2}' $1`"
if [ ! -n "$VAL" ]; then if [ -n "$IS_DESKTOP_RESULT" ]; then
VAL=`grep '^Name=' $1 | head -1`
fi
if [ -n "$VAL" ]; then
NAME=`echo $VAL | awk -F= '{printf("%s", $2);}'`
echo $NAME | tr -d '\n'
return 0 return 0
fi fi
fi fi
IS_DESKTOP_RESULT=""
return 1 return 1
} }
# function to get the sortorder list -if there is one # function to get the sortorder list -if there is one
get_sortorder() { get_sortorder() {
if [ -f $1"/.order" ]; then if [ -f "${1}/.order" ]; then
VAL=`cat $1"/.order" | awk '{printf("%s ", $1);}' | sed "s/,/ /g"` VAL="`awk '{printf("%s ", $1);}' $1"/.order" | sed 's/,/ /g'`"
else else
VAL="" VAL=""
fi fi
FILES=`/bin/ls $1 | awk '{printf("%s ", $1);}'` GET_SORT_ORDER_RESULT="$VAL"
VAL2=$VAL for I in `/bin/ls "$1"`; do
for I in $FILES; do
IS_IN="n" IS_IN="n"
for J in $VAL; do for J in $VAL; do
if [ "$J" = "$I" ]; then if [ "$J" = "$I" ]; then
IS_IN="y" IS_IN="y"
continue 2
fi fi
done done
if [ "$IS_IN" = "n" ]; then GET_SORT_ORDER_RESULT="${GET_SORT_ORDER_RESULT}${I} "
VAL2=$VAL2$I" "
fi
done done
echo $VAL2
return 0 return 0
} }
get_icon() { get_icon() {
VAL=`grep '^Icon=' $1 | head -1` VAL2="`awk -F= '$1 ~ "^Icon$" {printf("%s", $2); exit;}' $1`"
if [ -n "$VAL" ]; then if [ -z "$VAL2" ]; then
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}'` GET_ICON_RETURN=""
return 1
fi
# If we have "convert" and the icon havsn't already been scaled down, scale # If we have "convert" and the icon havsn't already been scaled down, scale
# it down now! # it down now!
EICONDIR="$ODIR/gnome_icons" GET_ICON_RETURNDIR="${ODIR}/gnome_icons"
if [ ! -d $EICONDIR ];then if [ ! -d "$GET_ICON_RETURNDIR" ];then
mkdir $EICONDIR mkdir "$GET_ICON_RETURNDIR"
fi fi
# The "Icon" entery can contain an absolute path, if it does forget the # The "Icon" entery can contain an absolute path, if it does forget the
# $GICONDIR # $GICONDIR
VAL3=`echo $VAL2 | grep /` VAL3="`echo $VAL2 | grep /`"
if [ "$VAL3" != "$VAL2" ];then if [ "$VAL3" != "$VAL2" ];then
if [ -n "$VAL2" ]; then if [ -n "$VAL2" ]; then
GICON=$GICONDIR/$VAL2 GICON="$GICONDIR/$VAL2"
EICON=$EICONDIR/$VAL2 GET_ICON_RETURN="$GET_ICON_RETURNDIR/$VAL2"
fi fi
else else
if [ -n "$VAL3" ]; then if [ -n "$VAL3" ]; then
GICON=$VAL3 GICON="$VAL3"
EICON=$EICONDIR/"`basename "$VAL3"`" GET_ICON_RETURN="$GET_ICON_RETURNDIR/`basename "$VAL3"`"
fi fi
fi fi
CONVERT=`which convert` if [ -n "$CONVERT_CMD" -a -n "$GICON" -a -f "$GICON" -a ! \
if [ -n "$CONVERT" ]; then -f "$GET_ICON_RETURN" ]; then
if [ -n "$GICON" ]; then "$CONVERT_CMD" "$GICON" -geometry 16x16 "$GET_ICON_RETURN"
if [ -f "$GICON" ]; then
if [ ! -f "$EICON" ]; then
$CONVERT $GICON -geometry 16x16 $EICON
fi fi
fi
fi
fi
echo "$EICON" | tr -d '\n'
return 0 return 0
fi
return 1
} }
get_exec() { get_exec() {
VAL=`grep '^Exec=' $1 | head -1` GET_EXEC_RETURN="`awk -F= '$1 ~ "^Exec$" {printf("%s", $2);}' $1`"
if [ -n "$VAL" ]; then if [ -z "$GET_EXEC_RETURN" ]; then
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}'` GET_EXEC_RETURN=""
echo $VAL2 | tr -d '\n'
return 0
fi
return 1 return 1
fi
return 0
} }
E_TITLE="GNOME Menu" E_TITLE="GNOME Menu"
@ -219,41 +244,48 @@ ORDER=""
# if a .directory file exists - read it # if a .directory file exists - read it
F=$DIR"/.directory" F=$DIR"/.directory"
if [ -f $F ]; then if [ -f $F ]; then
NAME=`is_desktop $F` is_desktop $F
NAME="$IS_DESKTOP_RESULT"
if [ -n "$NAME" ]; then if [ -n "$NAME" ]; then
E_TITLE=$NAME E_TITLE="$NAME"
fi fi
fi fi
ORDER=`get_sortorder $DIR` get_sortorder "$DIR"
ORDER="$GET_SORT_ORDER_RESULT"
# print the menu title # print the menu title
echo \"$E_TITLE\" > $OUT echo \"$E_TITLE\" > $OUT
# for every subdir in the dir list or order - print it # for every subdir in the dir list or order - print it
for F in $ORDER; do for F in $ORDER; do
FF=$DIR"/"$F FF="${DIR}/${F}"
if [ -d "$FF" ]; then if [ -d "$FF" ]; then
FFF=$FF"/.directory" FFF="${FF}/.directory"
if [ -f $FFF ]; then if [ -f "$FFF" ]; then
NAME=`is_desktop $FFF` is_desktop "$FFF"
NAME="$IS_DESKTOP_RESULT"
else else
NAME=`echo $F | sed "s/_/ /g"` NAME="`echo $F | sed 's/_/ /g'`"
fi fi
FFF=$ODIR"/"$BASE FFF="${ODIR}/${BASE}"
if [ ! -d "$FFF" ]; then if [ ! -d "$FFF" ]; then
mkdir $FFF mkdir "$FFF"
fi fi
MFILE=$FFF"/"$F.menu MFILE="${FFF}/${F}.menu"
$0 $BASE"/"$F $ODIR $MFILE $DIR"/"$F "$0" "${BASE}/${F}" "$ODIR" "$MFILE" "${DIR}/${F}"
ICO=`get_icon $FF"/.directory"` get_icon "${FF}/.directory"
echo \"$NAME\" \"$ICO\" menu \"$MFILE\" >> $OUT ICO="$GET_ICON_RETURN"
echo "\"$NAME\" \"$ICO\" menu \"$MFILE\"" >> $OUT
else else
if [ -r "$FF" ]; then if [ -r "$FF" ]; then
NAME=`is_desktop $FF` is_desktop $FF
NAME="$IS_DESKTOP_RESULT"
if [ -n "$NAME" ]; then if [ -n "$NAME" ]; then
EXE=`get_exec $FF` get_exec "$FF"
ICO=`get_icon $FF` EXE="$GET_EXEC_RETURN"
echo \"$NAME\" \"$ICO\" exec \"$EXE\" >> $OUT get_icon "$FF"
ICO="$GET_ICON_RETURN"
echo "\"$NAME\" \"$ICO\" exec \"$EXE\"" >> $OUT
fi fi
fi fi
fi fi

View File

@ -31,90 +31,128 @@ if [ $# -lt 3 ]; then
exit exit
fi fi
# setup variables # setup variables
BASE=$1 BASE="$1"
ODIR=$2 ODIR="$2"
OUT=$3 OUT="$3"
set_IDIR() {
# hunt around and see where all the kde graphics have gone # hunt around and see where all the kde graphics have gone
IDIR=/usr/share/icons IDIR=/usr/share/icons
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/local/share/icons IDIR="/usr/local/share/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/opt/kde/icons IDIR="/opt/kde/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/opt/kde/share/icons IDIR="/opt/kde/share/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/local/kde/icons IDIR="/usr/local/kde/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/local/kde/share/icons IDIR="/usr/local/kde/share/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/kde/icons IDIR="/usr/kde/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/kde/share/icons IDIR="/usr/kde/share/icons"
else
return
fi fi
if [ ! -r $IDIR"/mini/kcontrol.xpm" ]; then if [ ! -r "${IDIR}/mini/kcontrol.xpm" ]; then
IDIR=/usr/share/kde/icons IDIR="/usr/share/kde/icons"
else
return
fi fi
}
set_DIR (){
DIR=/usr/share/applnk
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/local/share/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/opt/kde/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/opt/kde/share/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/local/kde/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/local/kde/share/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/kde/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/kde/share/applnk"
else
return
fi
if [ ! -r "${DIR}//KControl.kdelnk" ]; then
DIR="/usr/share/kde/applnk"
else
return
fi
}
set_IDIR
# mini icons are in the icons dir # mini icons are in the icons dir
MIDIR=$IDIR"/mini" MIDIR=$IDIR"/mini"
# hunt around and see where all the kde applnk stuff is # hunt around and see where all the kde applnk stuff is
if [ $# -eq 4 ]; then if [ $# -eq 4 ]; then
DIR=$4 DIR="$4"
else else
DIR=/usr/share/applnk set_DIR
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/local/share/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/opt/kde/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/opt/kde/share/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/local/kde/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/local/kde/share/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/kde/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/kde/share/applnk
fi
if [ ! -r $DIR"/KControl.kdelnk" ]; then
DIR=/usr/share/kde/applnk
fi
fi fi
# if the applnk dir doesn't exist in the end then exit # if the applnk dir doesn't exist in the end then exit
if [ ! -d "$DIR" ]; then if [ ! -d "$DIR" ]; then
exit exit
fi fi
# if the destination dir doesn't exist - create it # if the destination dir doesn't exist - create it
if [ ! -d "$ODIR" ]; then if [ ! -d "$ODIR" ]; then
mkdir $ODIR mkdir "$ODIR"
fi fi
# function to check its a KDE kdelnk file # function to check its a KDE kdelnk file
is_kdelnk() { is_kdelnk() {
VAL=`grep "\[KDE Desktop Entry\]" $1` VAL="`grep "\[KDE Desktop Entry\]" $1`"
IS_KDELNK_RETURN=""
if [ -n "$VAL" ]; then if [ -n "$VAL" ]; then
VAL=`grep "^Name\[$LANG\]=" $1 | head -1` IS_KDELNK_RETURN="`awk -F= 'BEGIN { n="" } END { printf("%s", n) } $1 ~ "^Name\\\['$LANG'\\\]" {n=$2;exit} $1 ~ "^Name$" {n=$2}' $1`"
if [ ! -n "$VAL" ]; then if [ -n "$IS_KDELNK_RETURN" ]; then
VAL=`grep '^Name=' $1 | head -1`
fi
if [ -n "$VAL" ]; then
NAME=`echo $VAL | awk -F= '{printf("%s", $2);}'`
echo $NAME | tr -d '\n'
return 0 return 0
fi fi
fi fi
@ -123,55 +161,42 @@ is_kdelnk() {
# function to get the sortorder list -if there is one # function to get the sortorder list -if there is one
get_sortorder() { get_sortorder() {
VAL=`grep '^SortOrder=' $1 | head -1` GET_SORTORDER_RETURN="`awk -F= '$1 ~ "^SortOrder$" {printf("%s", $2);}' $1 | sed 's/,/ /g'`"
if [ -n "$VAL" ]; then if [ -z "$GET_SORTORDER_RETURN" ]; then
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}' | sed "s/,/ /g"`
echo $VAL2 | tr -d '\n'
return 0
fi
return 1 return 1
fi
return 0
} }
get_icon() { get_icon() {
VAL=`grep '^Icon=' $1 | head -1` GET_ICON_RETURN="`awk -F= '$1 ~ "^Icon$" {printf("%s", $2); exit;}' $1`"
if [ -n "$VAL" ]; then if [ -z "$GET_ICON_RETURN" ]; then
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}'`
echo $VAL2 | tr -d '\n'
return 0
fi
return 1 return 1
fi
return 0
} }
get_miniicon() { get_miniicon() {
VAL=`grep '^MiniIcon=' $1 | head -1` GET_MINIICON_RETURN="`awk -F= '$1 ~ "^MiniIcon$" {printf("%s", $2); exit;}' $1`"
if [ -n "$VAL" ]; then if [ -z "$GET_MINIICON_RETURN" ]; then
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}'` if ! get_icon $1; then
echo $VAL2 | tr -d '\n'
return 0
else
get_icon $1
return 0
fi
return 1 return 1
fi
GET_MINIICON_RETURN=$GET_ICON_RETURN
fi
return 0
} }
get_exec() { get_exec() {
VAL=`grep '^Exec=' $1 | head -1` GET_EXEC_RETURN=`awk -F= '$1 ~ "^Exec$" {printf("%s", $2); exit;}' $1 | \
if [ -n "$VAL" ]; then sed -e "s:\%c:$2:g" -e "s:\%m:$3:g" \
VAL2=`echo $VAL | awk -F= '{printf("%s", $2);}'` -e "s:\%i:$4:g" -e "s:\":\':g" \
VAL2=`echo $VAL2 | sed "s:\%c:$2:g"` -e "s:\%(u|k|n):NONE:g" -e "s:\%f:blank:g" \
VAL2=`echo $VAL2 | sed "s:\%m:$3:g"` -e "s:\%d:$HOME:g"`
VAL2=`echo $VAL2 | sed "s:\%i:$4:g"` if [ -z "$GET_EXEC_RETURN" ]; then
VAL2=`echo $VAL2 | sed "s:\":\':g"`
VAL2=`echo $VAL2 | sed "s:\%u:NONE:g"`
VAL2=`echo $VAL2 | sed "s:\%k:NONE:g"`
VAL2=`echo $VAL2 | sed "s:\%f:blank:g"`
VAL2=`echo $VAL2 | sed "s:\%n:NONE:g"`
VAL2=`echo $VAL2 | sed "s:\%d:$HOME:g"`
echo $VAL2 | tr -d '\n'
return 0
fi
return 1 return 1
fi
return 0
} }
E_TITLE="$DIR Menu" E_TITLE="$DIR Menu"
@ -179,13 +204,15 @@ E_TITLE="$DIR Menu"
# order of the directory # order of the directory
DIRORDER="" DIRORDER=""
# if a .directory file exists - read it # if a .directory file exists - read it
F=$DIR"/.directory" F="${DIR}/.directory"
if [ -f $F ]; then if [ -f $F ]; then
NAME=`is_kdelnk $F` is_kdelnk "$F"
NAME="$IS_KDELNK_RETURN"
if [ -n "$NAME" ]; then if [ -n "$NAME" ]; then
E_TITLE=$NAME E_TITLE="$NAME"
fi fi
DIRORDER=`get_sortorder $F` get_sortorder "$F"
DIRORDER="$GET_SORTORDER_RETURN"
fi fi
# this is to build a complete orderered list # this is to build a complete orderered list
@ -193,70 +220,77 @@ fi
# because DIRORDER is often not complete # because DIRORDER is often not complete
build_complete_order() { build_complete_order() {
DIRLIST=`/bin/ls -F $DIR | grep "/$" | sed "s:/::g"` DIRLIST=`/bin/ls -F $DIR | grep "/$" | sed "s:/::g"`
BUILD_COMPLETE_ORDER_RETURN=""
if [ -z "$DIRORDER" ]; then if [ -z "$DIRORDER" ]; then
echo $DIRLIST BUILD_COMPLETE_ORDER_RETURN="$DIRLIST"
else else
echo $DIRORDER BUILD_COMPLETE_ORDER_RETURN="$DIRORDER"
for subdir in $DIRLIST; do for subdir in $DIRLIST; do
# if not in DIRLIST # if not in DIRLIST
pos1=`echo $DIRORDER | grep "^$subdir "` pos="`echo $DIRORDER | egrep "(^$subdir | $subdir | $subdir$)"`"
pos2=`echo $DIRORDER | grep " $subdir "`
pos3=`echo $DIRORDER | grep " $subdir$"`
# case ^$subdir$ not possible because more than one sub-directory # case ^$subdir$ not possible because more than one sub-directory
if [ -z "$pos2" -a -z "$pos1" -a -z "$pos3" ]; then if [ -z "$pos" ]; then
echo $subdir BUILD_COMPLETE_ORDER="${BUILD_COMPLETE_ORDER_RETURN} ${subdir}"
fi fi
done done
fi fi
return 0
} }
ORDER=`build_complete_order` build_complete_order
ORDER="$BUILD_COMPLETE_ORDER_RETURN"
# print the menu title # print the menu title
echo \"$E_TITLE\" > $OUT echo "\"$E_TITLE\"" > $OUT
# for every subdir in the dir list or order - print it # for every subdir in the dir list or order - print it
for F in $ORDER; do for F in $ORDER; do
FF=$DIR"/"$F FF="${DIR}/${F}"
if [ -d "$FF" ]; then if [ -d "$FF" ]; then
NAME=`echo $F | sed "s/_/ /g"` NAME="`echo "$F" | sed "s/_/ /g"`"
FFF=$FF"/.directory" FFF="${FF}/.directory"
if [ -f "$FFF" ]; then if [ -f "$FFF" ]; then
ICON=`get_icon "$FFF"` get_icon "$FFF"
ICON="$GET_ICON_RETURN"
else else
ICON="" ICON=""
fi fi
if [ -n "$ICON" ]; then if [ -n "$ICON" ]; then
ICON=\"$MIDIR"/"$ICON\" ICON="\"${MIDIR}/${ICON}\""
else else
ICON=NULL ICON="NULL"
fi fi
FFF=$ODIR"/"$BASE FFF="${ODIR}/${BASE}"
if [ ! -d "$FFF" ]; then if [ ! -d "$FFF" ]; then
mkdir $FFF mkdir "$FFF"
fi fi
MFILE=$FFF"/"$F.menu MFILE="${FFF}/${F}.menu"
$0 $BASE"/"$F $ODIR $MFILE $DIR"/"$F "$0" "${BASE}/${F}" "$ODIR" "$MFILE" "${DIR}/${F}"
echo \"$NAME\" $ICON menu \"$MFILE\" >> $OUT echo "\"$NAME\" $ICON menu \"$MFILE\"" >> $OUT
fi fi
done done
# for all normal files... # for all normal files...
FILES=`/bin/ls -F $DIR | grep -v "/$"` FILES="`/bin/ls -F $DIR | grep -v "/$"`"
for F in $FILES; do for F in $FILES; do
FF=$DIR"/"$F FF="${DIR}/${F}"
if [ -f "$FF" ]; then if [ -f "$FF" ]; then
NAME=`is_kdelnk $FF` is_kdelnk "$FF"
NAME="$IS_KDELNK_RETURN"
if [ -n "$NAME" ]; then if [ -n "$NAME" ]; then
ICON=`get_miniicon "$FF"` get_miniicon "$FF"
BICON=`get_icon $FF` ICON="$GET_MINIICON_RETURN"
get_icon "$FF"
BICON="$GET_ICON_RETURN"
if [ -n "$ICON" ]; then if [ -n "$ICON" ]; then
ICON=\"$MIDIR"/"$ICON\" ICON="\"${MIDIR}/${ICON}\""
else else
ICON=NULL ICON="NULL"
fi fi
EXE=`get_exec $FF $NAME $ICON $BICON` get_exec "$FF" "$NAME" "$ICON $BICON"
echo \"$NAME\" $ICON exec \"$EXE\" >> $OUT EXE="$GET_EXEC_RETURN"
echo "\"$NAME\" $ICON exec \"$EXE\"" >> $OUT
fi fi
fi fi
done done

View File

@ -30,8 +30,13 @@ export PATH
OUT_DIR=$ECONFDIR OUT_DIR=$ECONFDIR
OUT=$OUT_DIR"/file.menu" OUT=$OUT_DIR"/file.menu"
WINDOWID=`eesh -ewait window_list | awk '$3 ~ "^Message$" { printf("%s ", $1)}'`
for i in $WINDOWID; do
eesh -e "win_op "$i" close"
done
eesh -e "dialog_ok Menus are being generated... Please Wait." eesh -e "dialog_ok Menus are being generated... Please Wait."
WINDOWID=`eesh -ewait window_list | grep Message | awk '{printf("%s", $1);}'` WINDOWID=`eesh -ewait window_list | awk '$3 ~ "^Message$" { printf("%s ", $1)}'`
e_gen_kde_menu menus_kde $OUT_DIR $OUT_DIR"/kde.menu" e_gen_kde_menu menus_kde $OUT_DIR $OUT_DIR"/kde.menu"
e_gen_gnome_menu menus_gnome $OUT_DIR $OUT_DIR"/gnome.menu" e_gen_gnome_menu menus_gnome $OUT_DIR $OUT_DIR"/gnome.menu"
@ -62,14 +67,12 @@ touch $OUT
# generate menu looking for Epplets - you might not have any yet.... but expect to # generate menu looking for Epplets - you might not have any yet.... but expect to
OUT=$OUT_DIR"/epplets.menu" OUT=$OUT_DIR"/epplets.menu"
EPPLETS=`/bin/ls $EBIN"/"*.epplet 2> /dev/null | awk '{printf("%s ", $1);}'` EPPLETS="`/bin/ls $EBIN"/"*.epplet 2> /dev/null`"
if [ -n "$EPPLETS" ]; then if [ -n "$EPPLETS" ]; then
echo \"Enlightenment Epplets\" > $OUT echo \"Enlightenment Epplets\" > $OUT
for I in $EPPLETS; do echo "$EPPLETS" | \
NAME=`echo $I | sed 's/.epplet//g'` sed -e 's:\(^.*/\([^/]*\).epplet$\):\"\2\" \"'$EROOT'/epplet_icons/\2.icon\" exec \"\1\":' \
NAME=`basename $NAME` >> $OUT
echo \"$NAME\" \"$EROOT"/epplet_icons/"$NAME".icon"\" exec \"$I\" >> $OUT
done
fi fi
touch $OUT touch $OUT
@ -106,6 +109,9 @@ if [ ! -f "$OUT" ]; then
echo \"Myth 2\" NULL exec \"myth2\" >> $OUT echo \"Myth 2\" NULL exec \"myth2\" >> $OUT
fi fi
touch $OUT touch $OUT
eesh -e "win_op "$WINDOWID" close"
for i in $WINDOWID; do
eesh -e "win_op "$i" close"
done
eesh -e "reload_menus" eesh -e "reload_menus"
eesh -e "dialog_ok Menu generation complete." eesh -e "dialog_ok Menu generation complete."