mostly cosmetic changes (tabs -> spaces),

added 'cli_find' which does the same as 'normal_find' but 
creates entries for cli-programs
This commit is contained in:
mathias 2005-03-17 11:34:24 +00:00
parent 859f167cba
commit f59f5e6c5a

View file

@ -47,14 +47,14 @@
WHOAMI=`whoami` WHOAMI=`whoami`
[ "$WHOAMI" = root ] && PATH=/bin:/usr/bin/:/usr/local/bin:/usr/X11R6/bin [ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
# Check for Imlib2-support # Check for Imlib2-support
if fluxbox -info 2> /dev/null | grep -q "^IMLIB"; then if fluxbox -info 2> /dev/null | grep -q "^IMLIB"; then
PNG_ICONS="yes" PNG_ICONS="yes"
else else
# better assume to assume "no" # better assume to assume "no"
PNG_ICONS="no" PNG_ICONS="no"
fi fi
# Functions # Functions
@ -82,7 +82,7 @@ Options:
-i other path(s) to search for icons -i other path(s) to search for icons
e.g., "/usr/kde/3.3/share/icons/crystalsvg/16x16/*" e.g., "/usr/kde/3.3/share/icons/crystalsvg/16x16/*"
-is wider search for icons (worth the extra time) -is wider search for icons (worth the extra time)
-in skip icon search -in skip icon search
-t Favourite terminal -t Favourite terminal
-w Homepage for console-browsers. Default is fluxbox.org -w Homepage for console-browsers. Default is fluxbox.org
@ -125,7 +125,7 @@ EOF
# some which's have a reliable return code, some don't # some which's have a reliable return code, some don't
# Lets figure out which which we have. # Lets figure out which which we have.
if which this_program_does_not_exist-no_really-aA1zZ9 >/dev/null 2>/dev/null; then if which this_program_does_not_exist-no_really-aA1zZ9 2> /dev/null 1> /dev/null; then
# can't rely on return value # can't rely on return value
find_it() { find_it() {
file=`which $1 2> /dev/null` file=`which $1 2> /dev/null`
@ -167,296 +167,296 @@ replaceWithinString(){
} }
convertIcon(){ convertIcon(){
if [ ! -f "$1" ] ; then if [ ! -f "$1" ] ; then
echo "Icon file not found: $1" >&2 echo "Icon file not found: $1" >&2
return 1 return 1
fi fi
if [ "$1" = "$2" ]; then if [ "$1" = "$2" ]; then
# $dnlamVERBOSE "Files are in the same location: $1 = $2" >&2 # $dnlamVERBOSE "Files are in the same location: $1 = $2" >&2
# not really an error; just nothing to do. # not really an error; just nothing to do.
return 0; return 0;
fi fi
local BASENAME local BASENAME
BASENAME="${1##*/}" BASENAME="${1##*/}"
# make sure it is an icon by checking if it has an extension # make sure it is an icon by checking if it has an extension
if [ "$BASENAME" = "${BASENAME%%.*}" ]; then if [ "$BASENAME" = "${BASENAME%%.*}" ]; then
# $dnlamVERBOSE "File $1 does not have a filename extention." >&2 # $dnlamVERBOSE "File $1 does not have a filename extention." >&2
return 1; return 1;
fi fi
# don't have to convert xpm files # don't have to convert xpm files
case "$1" in case "$1" in
*.xpm) *.xpm)
echo "$1" echo "$1"
return 0; return 0;
;; ;;
esac esac
# may not have to convert png if imlib is enabled # may not have to convert png if imlib is enabled
if [ "$PNG_ICONS" = "yes" ]; then if [ "$PNG_ICONS" = "yes" ]; then
case "$1" in case "$1" in
*.png) *.png)
echo "$1" echo "$1"
return 0; return 0;
;; ;;
esac esac
fi fi
# convert all others icons and save it as xpm format under directory $2 # convert all others icons and save it as xpm format under directory $2
entry_icon="$2/${BASENAME%.*}.xpm" entry_icon="$2/${BASENAME%.*}.xpm"
if [ -f "${entry_icon}" ]; then if [ -f "${entry_icon}" ]; then
: echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2
else else
if which convert &> /dev/null; then if which convert &> /dev/null; then
convert "$1" "$entry_icon" convert "$1" "$entry_icon"
# echo convert "$1" , "$entry_icon" >> $ICONMAPPING # echo convert "$1" , "$entry_icon" >> $ICONMAPPING
else else
echo "Please install ImageMagick's convert utility" >&2 echo "Please install ImageMagick's convert utility" >&2
fi fi
fi fi
echo "$entry_icon" echo "$entry_icon"
} }
removePath(){ removePath(){
execname="$1" execname="$1"
local progname local progname
progname="${execname%% *}" progname="${execname%% *}"
# separate program name and its parameters # separate program name and its parameters
if [ "$progname" = "$execname" ]; then if [ "$progname" = "$execname" ]; then
# no params # no params
# remove path from only program name # remove path from only program name
execname="${progname##*/}" execname="${progname##*/}"
else else
local params local params
params="${execname#* }" params="${execname#* }"
# remove path from only program name # remove path from only program name
execname="${progname##*/} $params" execname="${progname##*/} $params"
fi fi
echo $execname echo $execname
} }
doSearchLoop(){ doSearchLoop(){
for ICONPATH in "$@"; do for ICONPATH in "$@"; do
## $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING ## $dnlamVERBOSE ": $ICONPATH" >> $ICONMAPPING
[ -d "$ICONPATH" ] || continue [ -d "$ICONPATH" ] || continue
#echo -n "." #echo -n "."
# # $dnlamVERBOSE ":: $ICONPATH/$temp_icon" >> $ICONMAPPING # # $dnlamVERBOSE ":: $ICONPATH/$temp_icon" >> $ICONMAPPING
if [ -f "$ICONPATH/$temp_icon" ]; then if [ -f "$ICONPATH/$temp_icon" ]; then
echo "$ICONPATH/$temp_icon" echo "$ICONPATH/$temp_icon"
return 0; return 0;
else # try different extensions; else # try different extensions;
# remove extension # remove extension
iconNOext="${temp_icon%%.*}" iconNOext="${temp_icon%%.*}"
[ -d "$ICONPATH" ] && for ICONEXT in .xpm .png .gif ; do [ -d "$ICONPATH" ] && for ICONEXT in .xpm .png .gif ; do
## echo "::: $ICONPATH/$iconNOext$ICONEXT" >> $ICONMAPPING ## echo "::: $ICONPATH/$iconNOext$ICONEXT" >> $ICONMAPPING
if [ -f "$ICONPATH/$iconNOext$ICONEXT" ]; then if [ -f "$ICONPATH/$iconNOext$ICONEXT" ]; then
echo "$ICONPATH/$iconNOext$ICONEXT" echo "$ICONPATH/$iconNOext$ICONEXT"
return 0; return 0;
fi fi
done done
fi fi
done done
#echo "done" #echo "done"
return 1 return 1
} }
doSearch(){ doSearch(){
# remove '(' from '(fluxbox ...) | ...' # remove '(' from '(fluxbox ...) | ...'
local execname temp_icon local execname temp_icon
execname=`replaceWithinString "$1" "\("` execname=`replaceWithinString "$1" "\("`
temp_icon="$2" temp_icon="$2"
# $dnlamVERBOSE "# Searching for icon $temp_icon for $execname" >> $ICONMAPPING # $dnlamVERBOSE "# Searching for icon $temp_icon for $execname" >> $ICONMAPPING
# check in $ICONMAPPING before searching directories # check in $ICONMAPPING before searching directories
entry_icon=`grep -m 1 "^\"${execname}\"" $ICONMAPPING | grep -o '<.*>'` entry_icon=`grep -m 1 "^\"${execname}\"" $ICONMAPPING | grep -o '<.*>'`
if [ -n "$entry_icon" ]; then if [ -n "$entry_icon" ]; then
entry_icon=`replaceWithinString "$entry_icon" "<"` entry_icon=`replaceWithinString "$entry_icon" "<"`
entry_icon=`replaceWithinString "$entry_icon" ">"` entry_icon=`replaceWithinString "$entry_icon" ">"`
echo $entry_icon echo $entry_icon
return 0; return 0;
fi fi
# echo "$ICONMAPPING for $execname: $entry_icon" # echo "$ICONMAPPING for $execname: $entry_icon"
# the following paths include a user-defined variable, listing paths to search for icons # the following paths include a user-defined variable, listing paths to search for icons
# echo -n "for $temp_icon" # echo -n "for $temp_icon"
eval doSearchLoop $USER_ICONPATHS \ eval doSearchLoop $USER_ICONPATHS \
"$FB_ICONDIR" \ "$FB_ICONDIR" \
"/usr/share/${execname%% *}" \ "/usr/share/${execname%% *}" \
${OTHER_ICONPATHS} \ ${OTHER_ICONPATHS} \
} }
searchForIcon(){ searchForIcon(){
# remove '&' and everything after it # remove '&' and everything after it
entry_exec="${1%%&*}" entry_exec="${1%%&*}"
entry_icon="$2" entry_icon="$2"
# $dnlamVERBOSE echo "searchForIcon \"$entry_exec\" \"$entry_icon\"" >&2 # $dnlamVERBOSE echo "searchForIcon \"$entry_exec\" \"$entry_icon\"" >&2
# get the basename and parameters of entry_exec -- no path # get the basename and parameters of entry_exec -- no path
entry_exec=`removePath "${entry_exec}"` entry_exec=`removePath "${entry_exec}"`
[ -z "$entry_exec" ] && { echo "Exec is NULL $1 with icon $2"; return 1; } [ -z "$entry_exec" ] && { echo "Exec is NULL $1 with icon $2"; return 1; }
# search for specified icon if it does not exists # search for specified icon if it does not exists
if [ -n "$entry_icon" ] && [ ! "$entry_exec" = "$entry_icon" ] && [ ! -f "$entry_icon" ]; then if [ -n "$entry_icon" ] && [ ! "$entry_exec" = "$entry_icon" ] && [ ! -f "$entry_icon" ]; then
# to search for icon in other paths, # to search for icon in other paths,
# get basename # get basename
local temp_icon local temp_icon
temp_icon="${entry_icon##*/}" temp_icon="${entry_icon##*/}"
# remove parameters # remove parameters
temp_icon="${temp_icon#* }" temp_icon="${temp_icon#* }"
# clear entry_icon until temp_icon is found # clear entry_icon until temp_icon is found
unset entry_icon unset entry_icon
if [ ! -f "$entry_icon" ]; then if [ ! -f "$entry_icon" ]; then
entry_icon=`doSearch "$entry_exec" "$temp_icon"` entry_icon=`doSearch "$entry_exec" "$temp_icon"`
fi fi
fi fi
# remove parameters # remove parameters
local execname local execname
execname="${entry_exec%% *}" execname="${entry_exec%% *}"
# echo "search for icon named $execname.{xpm,png,gif}" # echo "search for icon named $execname.{xpm,png,gif}"
if [ ! -f "$entry_icon" ]; then if [ ! -f "$entry_icon" ]; then
entry_icon=`doSearch "$entry_exec" "$execname"` entry_icon=`doSearch "$entry_exec" "$execname"`
fi fi
# ----------- done with search ------------ # ----------- done with search ------------
# $dnlamVERBOSE echo "::: $entry_icon" >&2 # $dnlamVERBOSE echo "::: $entry_icon" >&2
# convert icon file, if needed # convert icon file, if needed
if [ -f "$entry_icon" ] && [ -n "yes$ConvertIfNecessary" ]; then if [ -f "$entry_icon" ] && [ -n "yes$ConvertIfNecessary" ]; then
entry_icon=`convertIcon "$entry_icon" "$HOME/.fluxbox/icons"` entry_icon=`convertIcon "$entry_icon" "$HOME/.fluxbox/icons"`
# $dnlamVERBOSE echo ":::: $entry_icon" >&2 # $dnlamVERBOSE echo ":::: $entry_icon" >&2
fi fi
# remove path to icon; just get basename # remove path to icon; just get basename
local icon_base local icon_base
icon_base="${entry_icon##*/}" icon_base="${entry_icon##*/}"
# remove extension # remove extension
icon_base="${icon_base%%.*}" icon_base="${icon_base%%.*}"
# echo "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>" # echo "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>"
if [ -f "$entry_icon" ]; then if [ -f "$entry_icon" ]; then
# if icon exists and entry does not already exists, add it # if icon exists and entry does not already exists, add it
if ! grep -q -m 1 "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>" $ICONMAPPING 2> /dev/null; then if ! grep -q -m 1 "^.${entry_exec}.[[:space:]]*<.*/${icon_base}\....>" $ICONMAPPING 2> /dev/null; then
echo -e "\"${entry_exec}\" \t <${entry_icon}>" >> $ICONMAPPING echo -e "\"${entry_exec}\" \t <${entry_icon}>" >> $ICONMAPPING
else else
: echo "# mapping already exists for ${entry_exec}" >> $ICONMAPPING : echo "# mapping already exists for ${entry_exec}" >> $ICONMAPPING
fi fi
else else
echo "# No icon file found for $entry_exec" >> $ICONMAPPING echo "# No icon file found for $entry_exec" >> $ICONMAPPING
fi fi
} }
toSingleLine(){ echo "$@"; } toSingleLine(){ echo "$@"; }
createIconMapping(){ createIconMapping(){
# $dnlamVERBOSE "# creating `date`" >> $ICONMAPPING # $dnlamVERBOSE "# creating `date`" >> $ICONMAPPING
# $dnlamVERBOSE "# using desktop files in $@" >> $ICONMAPPING # $dnlamVERBOSE "# using desktop files in $@" >> $ICONMAPPING
# $dnlamVERBOSE "# searching for icons in `eval toSingleLine $OTHER_ICONPATHS`" >> $ICONMAPPING # $dnlamVERBOSE "# searching for icons in `eval toSingleLine $OTHER_ICONPATHS`" >> $ICONMAPPING
# need to determine when to use .fluxbox/icons/$execname.xpm over those listed in iconmapping # need to determine when to use .fluxbox/icons/$execname.xpm over those listed in iconmapping
# $dnlamVERBOSE echo "createIconMapping: $@" # $dnlamVERBOSE echo "createIconMapping: $@"
for DIR in "$@" ; do for DIR in "$@" ; do
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
# $dnlamVERBOSE echo "# ------- Looking in $DIR" >&2 # $dnlamVERBOSE echo "# ------- Looking in $DIR" >&2
# >> $ICONMAPPING # >> $ICONMAPPING
find "$DIR" -type f -name "*.desktop" | while read DESKTOP_FILE; do find "$DIR" -type f -name "*.desktop" | while read DESKTOP_FILE; do
# echo $DESKTOP_FILE; # echo $DESKTOP_FILE;
#entry_name=`grep -m 1 '^[ ]*Name=' $DESKTOP_FILE` #entry_name=`grep -m 1 '^[ ]*Name=' $DESKTOP_FILE`
#entry_name=${entry_name##*=} #entry_name=${entry_name##*=}
entry_exec=`grep -m 1 '^[ ]*Exec=' "$DESKTOP_FILE"` entry_exec=`grep -m 1 '^[ ]*Exec=' "$DESKTOP_FILE"`
entry_exec=${entry_exec##*=} entry_exec=${entry_exec##*=}
entry_exec=`replaceWithinString "$entry_exec" "\""` entry_exec=`replaceWithinString "$entry_exec" "\""`
if [ -z "$entry_exec" ]; then if [ -z "$entry_exec" ]; then
entry_exec=${DESKTOP_FILE%%.desktop*} entry_exec=${DESKTOP_FILE%%.desktop*}
fi fi
entry_icon=`grep -m 1 '^[ ]*Icon=' "$DESKTOP_FILE"` entry_icon=`grep -m 1 '^[ ]*Icon=' "$DESKTOP_FILE"`
entry_icon=${entry_icon##*=} entry_icon=${entry_icon##*=}
# $dnlamVERBOSE echo "--- $entry_exec $entry_icon" >&2 # $dnlamVERBOSE echo "--- $entry_exec $entry_icon" >&2
case "$entry_icon" in case "$entry_icon" in
"" | mime_empty | no_icon ) "" | mime_empty | no_icon )
: echo "no icon for $entry_exec" : echo "no icon for $entry_exec"
;; ;;
*) *)
searchForIcon "$entry_exec" "$entry_icon" searchForIcon "$entry_exec" "$entry_icon"
;; ;;
esac esac
done done
fi fi
done done
# $dnlamVERBOSE "# done `date`" >> $ICONMAPPING # $dnlamVERBOSE "# done `date`" >> $ICONMAPPING
} }
lookupIcon() { lookupIcon() {
if [ ! -f "$ICONMAPPING" ]; then if [ ! -f "$ICONMAPPING" ]; then
echo "!!! Icon map file not found: $ICONMAPPING" >&2 echo "!!! Icon map file not found: $ICONMAPPING" >&2
return 1 return 1
fi fi
local execname local execname
execname="$1" execname="$1"
shift shift
[ -n "$1" ] && echo "!! Ignoring extra paramters: $*" >&2 [ -n "$1" ] && echo "!! Ignoring extra paramters: $*" >&2
[ -z "$execname" ] && { echo "execname is NULL; cannot lookup"; return 1; } [ -z "$execname" ] && { echo "execname is NULL; cannot lookup"; return 1; }
execname=`removePath "$execname"` execname=`removePath "$execname"`
#echo "grepping ${execname}" #echo "grepping ${execname}"
iconString=`grep -m 1 "^\"${execname}\"" $ICONMAPPING | grep -o '<.*>'` iconString=`grep -m 1 "^\"${execname}\"" $ICONMAPPING | grep -o '<.*>'`
# $dnlamVERBOSE "lookupIcon $execname, $iconString" >&2 # $dnlamVERBOSE "lookupIcon $execname, $iconString" >&2
if [ -z "$iconString" ] ; then if [ -z "$iconString" ] ; then
iconString=`grep -m 1 "^\"${execname%% *}" $ICONMAPPING | grep -o '<.*>'` iconString=`grep -m 1 "^\"${execname%% *}" $ICONMAPPING | grep -o '<.*>'`
fi fi
if [ -z "$iconString" ] && [ -z "$PARSING_DESKTOP" ] ; then if [ -z "$iconString" ] && [ -z "$PARSING_DESKTOP" ] ; then
## $dnlamVERBOSE "lookupIcon: Searching ... should only be needed for icons not gotten from *.desktop (manual-created ones): $execname" >&2 ## $dnlamVERBOSE "lookupIcon: Searching ... should only be needed for icons not gotten from *.desktop (manual-created ones): $execname" >&2
searchForIcon "$execname" "$execname" searchForIcon "$execname" "$execname"
[ -n "$entry_icon" ] && iconString="<$entry_icon>" [ -n "$entry_icon" ] && iconString="<$entry_icon>"
fi fi
# [ -n "$iconString" ] && echo " Found icon for $execname: $iconString" >&2 # [ -n "$iconString" ] && echo " Found icon for $execname: $iconString" >&2
echo $iconString echo $iconString
} }
append() { append() {
if [ -z "${INSTALL}" ]; then if [ -z "${INSTALL}" ]; then
# $dnlamVERBOSE echo "append: $*" >&2 # $dnlamVERBOSE echo "append: $*" >&2
local iconString local iconString
iconString="`echo $* | grep -o '<.*>'`" iconString="`echo $* | grep -o '<.*>'`"
# echo "iconString=$iconString" >&2 # echo "iconString=$iconString" >&2
if [ -z "$iconString" ] && [ -z "$NO_ICON" ]; then if [ -z "$iconString" ] && [ -z "$NO_ICON" ]; then
echo -n " $* " >> ${MENUFILENAME} echo -n " $* " >> ${MENUFILENAME}
# get the program name between '{}' from parameters # get the program name between '{}' from parameters
local execname local execname
execname="$*" execname="$*"
execname=${execname#*\{} execname=${execname#*\{}
execname=${execname%%\}*} execname=${execname%%\}*}
# $dnlamVERBOSE echo "execname=$execname" >&2 # $dnlamVERBOSE echo "execname=$execname" >&2
# if execname hasn't changed from original $*, then no '{...}' was given # if execname hasn't changed from original $*, then no '{...}' was given
if [ ! "$execname" = "$*" ]; then if [ ! "$execname" = "$*" ]; then
case "$execname" in case "$execname" in
$DEFAULT_TERM*) $DEFAULT_TERM*)
# remove quotes # remove quotes
execname=`replaceWithinString "$execname" "\""` execname=`replaceWithinString "$execname" "\""`
# remove "$DEFAULT_TERM -e " # remove "$DEFAULT_TERM -e "
# needed in case calling another program (e.g., vi) via "xterm -e" # needed in case calling another program (e.g., vi) via "xterm -e"
execname=${execname##*$DEFAULT_TERM -e } execname=${execname##*$DEFAULT_TERM -e }
;; ;;
esac esac
# lookup execname in icon map file # lookup execname in icon map file
iconString=`lookupIcon "$execname"` iconString=`lookupIcon "$execname"`
#[ -n "$iconString" ] || echo "No icon found for $execname" #[ -n "$iconString" ] || echo "No icon found for $execname"
fi fi
echo "${iconString}" >> ${MENUFILENAME} echo "${iconString}" >> ${MENUFILENAME}
else else
echo " $*" >> ${MENUFILENAME} echo " $*" >> ${MENUFILENAME}
fi fi
else else
echo " $*" >> ${MENUFILENAME} echo " $*" >> ${MENUFILENAME}
fi fi
@ -479,8 +479,8 @@ append_menu_end() {
menu_entry() { menu_entry() {
if [ -f "$1" ]; then if [ -f "$1" ]; then
# space&tab here # space&tab here
entry_name=`grep '^[ ]*Name=' "$1" | head -n 1 | cut -d = -f 2` entry_name=`grep '^[ ]*Name=' "$1" | head -n 1 | cut -d = -f 2`
entry_exec=`grep '^[ ]*Exec=' "$1" | head -n 1 | cut -d = -f 2` entry_exec=`grep '^[ ]*Exec=' "$1" | head -n 1 | cut -d = -f 2`
if [ -n "$entry_name" -a -n "$entry_exec" ]; then if [ -n "$entry_name" -a -n "$entry_exec" ]; then
append "[exec] ($entry_name) {$entry_exec}" append "[exec] ($entry_name) {$entry_exec}"
fi fi
@ -532,6 +532,13 @@ normal_find() {
done done
} }
cli_find() {
while [ "$1" ]; do
find_it $1 append "[exec] ($1) {${DEFAULT_TERM} -e $1}"
shift
done
}
clean_up() { clean_up() {
[ -f "$ICONMAPPING" ] && rm -f "$ICONMAPPING" [ -f "$ICONMAPPING" ] && rm -f "$ICONMAPPING"
@ -1235,33 +1242,33 @@ while [ $# -gt 0 ]; do
-B) BACKGROUNDMENUITEM=yes; shift;; -B) BACKGROUNDMENUITEM=yes; shift;;
-k) KDEMENU=yes; shift;; -k) KDEMENU=yes; shift;;
-g) GNOMEMENU=yes; shift;; -g) GNOMEMENU=yes; shift;;
-in) NO_ICON=yes; shift;; -in) NO_ICON=yes; shift;;
-is) OTHER_ICONPATHS=" -is) OTHER_ICONPATHS="
/usr{,/local}/share{,/xclass}/{icons,pixmaps} /usr{,/local}/share{,/xclass}/{icons,pixmaps}
/usr{,/local}/share/icons/mini /usr{,/local}/share/icons/mini
/usr{,/local}/{,X11R6/}share/icons/{default.kde,hicolor}/16x16/* /usr{,/local}/{,X11R6/}share/icons/{default.kde,hicolor}/16x16/*
" "
shift;; shift;;
-ds) OTHER_DESKTOP_PATHS=" -ds) OTHER_DESKTOP_PATHS="
/usr/share/mimelnk /usr/share/mimelnk
/usr/share/applications /usr/share/applications
/usr/share/xsessions /usr/share/xsessions
/usr/share/services /usr/share/services
" "
# /usr/share/apps \ # /usr/share/apps \
shift;; shift;;
-i) USER_ICONPATHS=${2}; -i) USER_ICONPATHS=${2};
#needs testing #needs testing
for aPath in $2; do for aPath in $2; do
testoption di $1 $aPath; testoption di $1 $aPath;
done done
shift 2;; shift 2;;
-d) USER_DESKTOP_PATHS=${2}; -d) USER_DESKTOP_PATHS=${2};
#needs testing #needs testing
for aPath in $2; do for aPath in $2; do
testoption di $1 $aPath; testoption di $1 $aPath;
done done
shift 2;; shift 2;;
-t) MY_TERM=${2}; testoption ex $1 $2; shift 2;; -t) MY_TERM=${2}; testoption ex $1 $2; shift 2;;
-b) MY_BROWSER=${2}; testoption ex $1 $2; shift 2;; -b) MY_BROWSER=${2}; testoption ex $1 $2; shift 2;;
-o) MENUFILENAME=${2}; shift 2; CHECKINIT=NO ;; -o) MENUFILENAME=${2}; shift 2; CHECKINIT=NO ;;
@ -1336,46 +1343,46 @@ for KDE_PREFIX in "${KDE_PREFIX}" /usr/local /usr/X11R6 /usr /opt "${PREFIX}"; d
done done
if [ -z "${INSTALL}" ] && [ -z "${NO_ICON}" ]; then if [ -z "${INSTALL}" ] && [ -z "${NO_ICON}" ]; then
# [ -z "$dnlamVERBOSE" ] && dnlamVERBOSE=": echo" # for debugging # [ -z "$dnlamVERBOSE" ] && dnlamVERBOSE=": echo" # for debugging
FB_ICONDIR="$HOME/.fluxbox/icons" FB_ICONDIR="$HOME/.fluxbox/icons"
[ -d "$FB_ICONDIR" ] || mkdir "$FB_ICONDIR" [ -d "$FB_ICONDIR" ] || mkdir "$FB_ICONDIR"
ICONMAPPING="$HOME/.fluxbox/iconmapping" ICONMAPPING="$HOME/.fluxbox/iconmapping"
if [ "$GNOMEMENU" ] ; then if [ "$GNOMEMENU" ] ; then
OTHER_DESKTOP_PATHS="\"$HOME/.gnome/apps\" \"${GNOME_PREFIX}/share/gnome/apps\" $OTHER_DESKTOP_PATHS" OTHER_DESKTOP_PATHS="\"$HOME/.gnome/apps\" \"${GNOME_PREFIX}/share/gnome/apps\" $OTHER_DESKTOP_PATHS"
#[ "OTHER_ICONPATHS" ] && OTHER_ICONPATHS= #[ "OTHER_ICONPATHS" ] && OTHER_ICONPATHS=
fi fi
if [ "$KDEMENU" ] ; then if [ "$KDEMENU" ] ; then
OTHER_DESKTOP_PATHS="\"$HOME/.kde/share/applnk\" \"${KDE_PREFIX}/share/applnk\" $OTHER_DESKTOP_PATHS" OTHER_DESKTOP_PATHS="\"$HOME/.kde/share/applnk\" \"${KDE_PREFIX}/share/applnk\" $OTHER_DESKTOP_PATHS"
[ "OTHER_ICONPATHS" ] && OTHER_ICONPATHS="\"$HOME\"/.kde/share/icons/{,*} $OTHER_ICONPATHS" [ "OTHER_ICONPATHS" ] && OTHER_ICONPATHS="\"$HOME\"/.kde/share/icons/{,*} $OTHER_ICONPATHS"
fi fi
[ "$GNOMEMENU$KDEMENU" ] && OTHER_DESKTOP_PATHS="\"$ETCAPPLNK\" $OTHER_DESKTOP_PATHS" [ "$GNOMEMENU$KDEMENU" ] && OTHER_DESKTOP_PATHS="\"$ETCAPPLNK\" $OTHER_DESKTOP_PATHS"
checkDirs(){ checkDirs(){
#echo checkDirs: $* >&2 #echo checkDirs: $* >&2
local CHECKED_DIRS="" local CHECKED_DIRS=""
for DIR in "$@"; do for DIR in "$@"; do
if [ -d "$DIR" ]; then if [ -d "$DIR" ]; then
# todo: should check if there are duplicates # todo: should check if there are duplicates
CHECKED_DIRS="$CHECKED_DIRS \"$DIR\"" CHECKED_DIRS="$CHECKED_DIRS \"$DIR\""
fi fi
done done
#echo checkDirs - $CHECKED_DIRS >&2 #echo checkDirs - $CHECKED_DIRS >&2
echo $CHECKED_DIRS echo $CHECKED_DIRS
} }
OTHER_ICONPATHS=`eval checkDirs $OTHER_ICONPATHS` OTHER_ICONPATHS=`eval checkDirs $OTHER_ICONPATHS`
OTHER_DESKTOP_PATHS=`eval checkDirs $OTHER_DESKTOP_PATHS` OTHER_DESKTOP_PATHS=`eval checkDirs $OTHER_DESKTOP_PATHS`
# $dnlamVERBOSE "Using USER_DESKTOP_PATHS=\"$USER_DESKTOP_PATHS\" and USER_ICONPATHS=\"$USER_ICONPATHS\"" # $dnlamVERBOSE "Using USER_DESKTOP_PATHS=\"$USER_DESKTOP_PATHS\" and USER_ICONPATHS=\"$USER_ICONPATHS\""
# $dnlamVERBOSE "Using OTHER_ICONPATHS=$OTHER_ICONPATHS" # $dnlamVERBOSE "Using OTHER_ICONPATHS=$OTHER_ICONPATHS"
# $dnlamVERBOSE "Using OTHER_DESKTOP_PATHS=$OTHER_DESKTOP_PATHS" # $dnlamVERBOSE "Using OTHER_DESKTOP_PATHS=$OTHER_DESKTOP_PATHS"
# $dnlamVERBOSE "Calling function: createIconMapping" # $dnlamVERBOSE "Calling function: createIconMapping"
# $dnlamVERBOSE "Creating $ICONMAPPING" >&2 # $dnlamVERBOSE "Creating $ICONMAPPING" >&2
touch "$ICONMAPPING" touch "$ICONMAPPING"
eval createIconMapping $USER_DESKTOP_PATHS $OTHER_DESKTOP_PATHS eval createIconMapping $USER_DESKTOP_PATHS $OTHER_DESKTOP_PATHS
# $dnlamVERBOSE "Done createIconMapping." # $dnlamVERBOSE "Done createIconMapping."
fi fi
# directory for the backgrounds # directory for the backgrounds
@ -1485,44 +1492,36 @@ append_submenu "${NETMENU}"
append_submenu IM append_submenu IM
normal_find gaim kopete gnomemeeting sim kadu psi normal_find gaim kopete gnomemeeting sim kadu psi
find_it licq append "[exec] (licq) {env QT_XFT=true licq}" find_it licq append "[exec] (licq) {env QT_XFT=true licq}"
find_it centericq append "[exec] (centericq) {${DEFAULT_TERM} -e centericq}" cli_find centericq micq
find_it micq append "[exec] (micq) {${DEFAULT_TERM} -e micq}"
append_menu_end append_menu_end
append_submenu Mail append_submenu Mail
normal_find sylpheed kmail evolution thunderbird mozilla-thunderbird normal_find sylpheed kmail evolution thunderbird mozilla-thunderbird \
find_it mutt append "[exec] (mutt) {${DEFAULT_TERM} -e mutt}" sylpheed-claws
cli_find mutt pine
append_menu_end append_menu_end
append_submenu News append_submenu News
normal_find liferea pears normal_find liferea pears
find_it slrn append "[exec] (slrn) {${DEFAULT_TERM} -e slrn}" cli_find slrn tin
append_menu_end append_menu_end
append_submenu IRC append_submenu IRC
normal_find xchat ksirc vyqchat lostirc logui konversation kvirc normal_find xchat ksirc vyqchat lostirc logui konversation kvirc
find_it irssi append "[exec] (irssi) {${DEFAULT_TERM} -e irssi}" cli_find irssi epic4 weechat ninja
find_it BitchX append "[exec] (BitchX) {${DEFAULT_TERM} -e BitchX -N}" || \ find_it BitchX append "[exec] (BitchX) {${DEFAULT_TERM} -e BitchX -N}" || \
find_it bitchx append "[exec] (BitchX) {${DEFAULT_TERM} -e bitchx -N}" find_it bitchx append "[exec] (BitchX) {${DEFAULT_TERM} -e bitchx -N}"
find_it ircii append "[exec] (ircii) {${DEFAULT_TERM} -e ircii -s}" find_it ircii append "[exec] (ircii) {${DEFAULT_TERM} -e ircii -s}"
find_it epic4 append "[exec] (epic4) {${DEFAULT_TERM} -e epic4}"
find_it weechat append "[exec] (weechat) {${DEFAULT_TERM} -e weechat}"
find_it ninja append "[exec] (ninja) {${DEFAULT_TERM} -e ninja}"
append_menu_end append_menu_end
append_submenu P2P append_submenu P2P
normal_find gtk-gnutella lopster nicotine pyslsk xmule amule dcgui-qt normal_find gtk-gnutella lopster nicotine pyslsk xmule amule dcgui-qt
find_it TekNap append "[exec] (TekNap) {${DEFAULT_TERM} -e TekNap}" cli_find TekNap giFTcurs
find_it giFTcurs append "[exec] (giFTcurs) {${DEFAULT_TERM} -e giFTcurs}"
append_menu_end append_menu_end
append_submenu ftp append_submenu ftp
normal_find gftp IglooFTP-PRO normal_find gftp IglooFTP-PRO
find_it ncftp append "[exec] (ncftp) {${DEFAULT_TERM} -e ncftp}" cli_find ncftp pftp ftp lftp yafc
find_it pftp append "[exec] (pftp) {${DEFAULT_TERM} -e pftp}"
find_it ftp append "[exec] (ftp) {${DEFAULT_TERM} -e ftp}"
find_it lftp append "[exec] (lftp) {${DEFAULT_TERM} -e lftp}"
find_it yafc append "[exec] (yafc) {${DEFAULT_TERM} -e yafc}"
append_menu_end append_menu_end
normal_find pan xnmap skype x3270 normal_find pan xnmap skype x3270
@ -1531,12 +1530,8 @@ append_menu_end
append_submenu "${EDITORMENU}" append_submenu "${EDITORMENU}"
normal_find gvim bluefish nedit gedit xedit kword kwrite kate anjuta \ normal_find gvim bluefish nedit gedit xedit kword kwrite kate anjuta \
wings xemacs emacs kvim cream wings xemacs emacs kvim cream evim
find_it nano append "[exec] (nano) {${DEFAULT_TERM} -e nano}" cli_find nano vim vi zile jed
find_it vi append "[exec] (vi) {${DEFAULT_TERM} -e vi}" ||\
find_it vim append "[exec] (vim) {${DEFAULT_TERM} -e vim}"
find_it zile append "[exec] (zile) {${DEFAULT_TERM} -e zile}"
find_it jed append "[exec] (jed) {${DEFAULT_TERM} -e jed}"
find_it emacs append "[exec] (emacs-nw) {${DEFAULT_TERM} -e emacs -nw}" find_it emacs append "[exec] (emacs-nw) {${DEFAULT_TERM} -e emacs -nw}"
find_it xemacs append "[exec] (xemacs-nw) {${DEFAULT_TERM} -e xemacs -nw}" find_it xemacs append "[exec] (xemacs-nw) {${DEFAULT_TERM} -e xemacs -nw}"
append_menu_end append_menu_end
@ -1544,7 +1539,7 @@ append_menu_end
append_submenu "${FILEUTILSMENU}" append_submenu "${FILEUTILSMENU}"
normal_find konqueror gentoo krusader linuxcmd rox tuxcmd krename xfe normal_find konqueror gentoo krusader linuxcmd rox tuxcmd krename xfe
find_it nautilus append "[exec] (nautilus) {nautilus --no-desktop}" find_it nautilus append "[exec] (nautilus) {nautilus --no-desktop}"
find_it mc append "[exec] (mc) {${DEFAULT_TERM} -e mc}" cli_find mc
append_menu_end append_menu_end
append_submenu "${MULTIMEDIAMENU}" append_submenu "${MULTIMEDIAMENU}"
@ -1562,9 +1557,7 @@ append_submenu "${MULTIMEDIAMENU}"
normal_find xmms noatun alsaplayer gqmpeg aumix xmixer gmix kmix kscd \ normal_find xmms noatun alsaplayer gqmpeg aumix xmixer gmix kmix kscd \
grecord kmidi xplaycd soundtracker grip easytag audacity \ grecord kmidi xplaycd soundtracker grip easytag audacity \
zinf rhythmbox kaboodle beep-media-player zinf rhythmbox kaboodle beep-media-player
find_it cdcd append "[exec] (cdcd) {${DEFAULT_TERM} -e cdcd}" cli_find cdcd cplay alsamixer orpheus mp3blaster
find_it cplay append "[exec] (cplay) {${DEFAULT_TERM} -e cplay}"
find_it alsamixer append "[exec] (AlsaMixer) {${DEFAULT_TERM} -e alsamixer}"
append_menu_end append_menu_end
@ -1608,8 +1601,9 @@ append_submenu "${GAMESMENU}"
gtali tuxracer xpenguins xsnow xeyes xpenguins smclone \ gtali tuxracer xpenguins xsnow xeyes xpenguins smclone \
openmortal quake2 quake3 skoosh same-gnome enigma xbill \ openmortal quake2 quake3 skoosh same-gnome enigma xbill \
icebreaker scorched3d sol dosbox black-box enigma freeciv \ icebreaker scorched3d sol dosbox black-box enigma freeciv \
freeciv-server frozen-bubble liquidwar qt-nethack gnugo \ freeciv-server frozen-bubble liquidwar qt-nethack \
nethack-gnome pathological scummvm xqf nethack-gnome pathological scummvm xqf
cli_find gnugo
find_it et append "[exec] (Enemy Territory) {et}" find_it et append "[exec] (Enemy Territory) {et}"
find_it ut append "[exec] (Unreal Tournament) {ut}" find_it ut append "[exec] (Unreal Tournament) {ut}"
@ -1746,12 +1740,12 @@ mv -f menu.tmp $MENUFILENAME
if [ -z "$INSTALL" ]; then if [ -z "$INSTALL" ]; then
if [ -z "$CHECKINIT" ]; then if [ -z "$CHECKINIT" ]; then
INITMENUFILENAME=`awk '/menuFile/ {print $2}' $HOME/.fluxbox/init` INITMENUFILENAME=`awk '/menuFile/ {print $2}' $HOME/.fluxbox/init`
INITMENUFILENAME=`replaceWithinString "$INITMENUFILENAME" "~" "$HOME"` INITMENUFILENAME=`replaceWithinString "$INITMENUFILENAME" "~" "$HOME"`
if [ ! "$INITMENUFILENAME" = "$MENUFILENAME" ]; then if [ ! "$INITMENUFILENAME" = "$MENUFILENAME" ]; then
echo "Note: In $HOME/.fluxbox/init, your \"session.menuFile\" does not point to $MENUFILENAME but to $INITMENUFILENAME" >&2 echo "Note: In $HOME/.fluxbox/init, your \"session.menuFile\" does not point to $MENUFILENAME but to $INITMENUFILENAME" >&2
fi fi
fi fi
echo "Menu successfully generated: $MENUFILENAME" echo "Menu successfully generated: $MENUFILENAME"
#echo " Make sure \"session.menuFile: $MENUFILENAME\" is in $HOME/.fluxbox/init." #echo " Make sure \"session.menuFile: $MENUFILENAME\" is in $HOME/.fluxbox/init."
echo 'Use fluxbox-generate_menu -h to read about all the latest features.' echo 'Use fluxbox-generate_menu -h to read about all the latest features.'
fi fi