a few little compatibility fixes (for old sh's and systems), plus Han
untabified it. Also some slight corrections to output messages.
This commit is contained in:
parent
271df70e9b
commit
a0611c9727
1 changed files with 295 additions and 278 deletions
|
@ -22,7 +22,7 @@
|
|||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# $Id: fluxbox-generate_menu,v 1.12 2002/11/17 17:36:50 fluxgen Exp $
|
||||
# $Id: fluxbox-generate_menu,v 1.13 2002/11/19 06:21:45 rathnor Exp $
|
||||
|
||||
[ `id -u` -eq 0 ] && PATH=/bin:/usr/bin/:/usr/local/bin:/usr/X11R6/bin
|
||||
|
||||
|
@ -30,21 +30,23 @@
|
|||
display_usage() {
|
||||
cat <<EOF
|
||||
|
||||
fluxbox-genrate_menu
|
||||
Usage: fluxbox-generate_menu [-kg] [-o /path]
|
||||
[-p /path] [-m menu-title]
|
||||
Usage: fluxbox-generate_menu [-kgr] [-t terminal] [-w browser]
|
||||
[-m menu-title] [-p /path] [-n /path] [-q /path] [-o /path]
|
||||
Options:
|
||||
|
||||
-t Favourite terminal
|
||||
-b Favourite browser
|
||||
-k Insert a kde menu
|
||||
-g Add a gnome menu
|
||||
-o Outputfile; default is ~/.fluxbox/menu
|
||||
-m Menu-title; default is "Fluxbox"
|
||||
-r Don't remove empty menu-entries; Better for templates.
|
||||
-o Outputfile; default is ~/.fluxbox/menu
|
||||
-t Favourite terminal
|
||||
-b Favourite browser
|
||||
-w Homepage for console-browsers. Default is fluxbox.org.
|
||||
|
||||
-h Display this help
|
||||
-a Display the authors of this script
|
||||
|
||||
|
||||
Only for packagers:
|
||||
|
||||
-p Package-datadir; default is /usr/share
|
||||
|
@ -58,8 +60,7 @@ display_help() {
|
|||
cat <<EOF
|
||||
|
||||
This program generates a menu-file for fluxbox.
|
||||
Use fluxbox-generate_menu -h for brief usage instructions
|
||||
|
||||
Use fluxbox-generate_menu -h for brief usage instructions.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -80,7 +81,17 @@ EOF
|
|||
}
|
||||
|
||||
find_it() {
|
||||
which $1 > /dev/null 2> /dev/null && shift && $*
|
||||
if [ -z "$1" ]; then
|
||||
# echo "Nothing found"
|
||||
return 1
|
||||
fi
|
||||
which $1 > /dev/null 2> /dev/null
|
||||
found=$?
|
||||
if [ $found -eq 0 -a $# -gt 1 ]; then
|
||||
shift
|
||||
$*
|
||||
fi
|
||||
return $found
|
||||
}
|
||||
|
||||
append() {
|
||||
|
@ -93,14 +104,14 @@ append_menu() {
|
|||
|
||||
append_submenu() {
|
||||
# only an empty line in templates
|
||||
[ ${REMOVE} ] && echo >> ${FILENAME}
|
||||
[ "${REMOVE}" ] && echo >> ${FILENAME}
|
||||
append_menu "[submenu] ($1)"
|
||||
}
|
||||
|
||||
append_menu_end() {
|
||||
append_menu "[end]"
|
||||
# only an empty line in templates
|
||||
[ ${REMOVE} ] && echo >> ${FILENAME}
|
||||
[ "${REMOVE}" ] && echo >> ${FILENAME}
|
||||
}
|
||||
|
||||
menu_entry() {
|
||||
|
@ -121,7 +132,7 @@ menu_entry_dir() {
|
|||
}
|
||||
|
||||
normal_find() {
|
||||
while [ $1 ]; do
|
||||
while [ "$1" ]; do
|
||||
find_it $1 append "[exec] ($1) {$1}"
|
||||
shift
|
||||
done
|
||||
|
@ -137,7 +148,7 @@ mv -f ${FILENAME}.tmp ${FILENAME}
|
|||
}
|
||||
|
||||
# Get options.
|
||||
while getopts ":khragb:t:p:n:q:o:m:" COMMAND_LINE_ARGUMENT ; do
|
||||
while getopts ":khragb:t:p:w:n:q:o:m:" COMMAND_LINE_ARGUMENT ; do
|
||||
case "${COMMAND_LINE_ARGUMENT}" in
|
||||
k) KDEMENU=yes ;;
|
||||
g) GNOMEMENU=yes ;;
|
||||
|
@ -148,6 +159,7 @@ while getopts ":khragb:t:p:n:q:o:m:" COMMAND_LINE_ARGUMENT ; do
|
|||
n) GPKGDATADIR=${OPTARG} ;;
|
||||
q) KPKGDATADIR=${OPTARG} ;;
|
||||
m) MENUTITLE=${OPTARG} ;;
|
||||
w) HOMEPAGE=${OPTARG} ;;
|
||||
r) REMOVE=no ;;
|
||||
h) display_usage ; exit 0 ;;
|
||||
a) display_authors ; exit 0 ;;
|
||||
|
@ -159,27 +171,32 @@ done
|
|||
# Set Defaults
|
||||
|
||||
# menufile name
|
||||
if [ -z ${FILENAME} ]; then
|
||||
if [ -z "${FILENAME}" ]; then
|
||||
FILENAME=${HOME}/.fluxbox/menu
|
||||
fi
|
||||
|
||||
# Can we actually create ${FILENAME}
|
||||
if ! touch ${FILENAME}; then
|
||||
echo "Fatal error: can't create $FILENAME" >/dev/stderr
|
||||
touch ${FILENAME} 2> /dev/null
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo "Fatal error: can't create $FILENAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# backup menu
|
||||
if [ -w ${FILENAME} ]; then
|
||||
if [ -w "${FILENAME}" ]; then
|
||||
if [ -f ${FILENAME}.firstbak ];then
|
||||
cp ${FILENAME} ${FILENAME}.firstbak
|
||||
fi
|
||||
mv ${FILENAME} ${FILENAME}.bak
|
||||
fi
|
||||
|
||||
# default homepage for console-browsers
|
||||
HOMEPAGE=${HOMEPAGE:=fluxbox.org}
|
||||
|
||||
#packagedatadir
|
||||
|
||||
if [ ! -d "${PKGDATADIR}" -o "${PKGDATADIR}" = "" ]; then
|
||||
if [ `uname` = "Linux" ];then
|
||||
if [ "`uname`" = "Linux" ];then
|
||||
PKGDATADIR=/usr/share
|
||||
else
|
||||
PKGDATADIR=/usr/local/share
|
||||
|
@ -204,7 +221,7 @@ fi
|
|||
# find the default terminal
|
||||
find_it $MY_TERM
|
||||
if [ $? -ne 0 ];then
|
||||
[ -n "$MY_TERM" ] && echo "Warning: you choose an invalid term." > /dev/stderr
|
||||
[ -n "$MY_TERM" ] && echo "Warning: you choose an invalid term." >&2
|
||||
#The precise order is up for debate.
|
||||
for term in Eterm aterm rxvt wterm xterm konsole gnome-terminal; do
|
||||
if find_it $term; then
|
||||
|
@ -220,7 +237,7 @@ fi
|
|||
# find the default browser
|
||||
find_it $MY_BROWSER
|
||||
if [ $? -ne 0 ];then
|
||||
[ -n "$MY_BROWSER" ] && echo "Warning: you choose an invalid browser." > /dev/stderr
|
||||
[ -n "$MY_BROWSER" ] && echo "Warning: you choose an invalid browser." >&2
|
||||
#The precise order is up for debate.
|
||||
for browser in opera phoenix mozilla galeon konqueror dillo netscape links w3m lynx; do
|
||||
if find_it $browser; then
|
||||
|
@ -235,7 +252,7 @@ fi
|
|||
|
||||
# a unix system without any terms. that's odd
|
||||
if [ -z "$DEFAULT_TERM" ];then
|
||||
cat <<EOF>/dev/stderr
|
||||
cat <<EOF>&2
|
||||
Error: I can't find any terminal-emulators in your path.
|
||||
Please specify your favourite terminal with the -t option.
|
||||
EOF
|
||||
|
@ -428,7 +445,7 @@ echo "[begin] (${MENUTITLE})" > ${FILENAME}
|
|||
append "[exec] (${DEFAULT_TERM}) {${DEFAULT_TERM}}"
|
||||
|
||||
case "$DEFAULT_BROWSER" in
|
||||
links|w3m|lynx) append "[exec] (${DEFAULT_BROWSER}) {${DEFAULT_TERM} -e ${DEFAULT_BROWSER} fluxbox.org}" ;;
|
||||
links|w3m|lynx) append "[exec] (${DEFAULT_BROWSER}) {${DEFAULT_TERM} -e ${DEFAULT_BROWSER} ${HOMEPAGE}}" ;;
|
||||
mozilla|phoenix|galeon|dillo|netscape) append "[exec] (${DEFAULT_BROWSER}) {${DEFAULT_BROWSER}}" ;;
|
||||
konqueror) append "[exec] (konqueror) {kfmclient openProfile webbrowsing}" ;;
|
||||
opera) append "[exec] (opera) {env QT_XFT=true opera}" ;;
|
||||
|
@ -447,9 +464,9 @@ append_submenu ${NETMENU}
|
|||
normal_find netscape galeon mozilla dillo
|
||||
find_it opera append "[exec] (opera) {env QT_XFT=true opera}"
|
||||
find_it konqueror append "[exec] (konqueror) {kfmclient openProfile webbrowsing}"
|
||||
find_it links append "[exec] (links) {${DEFAULT_TERM} -e links fluxbox.org}"
|
||||
find_it w3m append "[exec] (w3m) {${DEFAULT_TERM} -e w3m fluxbox.org}"
|
||||
find_it lynx append "[exec] (lynx) {${DEFAULT_TERM} -e lynx fluxbox.org}"
|
||||
find_it links append "[exec] (links) {${DEFAULT_TERM} -e links ${HOMEPAGE}}"
|
||||
find_it w3m append "[exec] (w3m) {${DEFAULT_TERM} -e w3m ${HOMEPAGE}}"
|
||||
find_it lynx append "[exec] (lynx) {${DEFAULT_TERM} -e lynx ${HOMEPAGE}}"
|
||||
append_menu_end
|
||||
|
||||
append_submenu IM
|
||||
|
@ -594,6 +611,6 @@ append_menu_end
|
|||
# this function removes empty menu items. It can not yet remove nested
|
||||
# empty submenus :\
|
||||
|
||||
if [ ! ${REMOVE} ];then
|
||||
if [ ! "${REMOVE}" ];then
|
||||
clean_up
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue