aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-10-08 14:18:25 (GMT)
committerrathnor <rathnor>2003-10-08 14:18:25 (GMT)
commit075dc35b5eeb875e971842e8230338395367e08f (patch)
tree448fa41227a09d1b774ec06e17c1632d4edffd86 /util
parentae729342e964c7b6d3571884b55ce14ff27fa553 (diff)
downloadfluxbox_pavel-075dc35b5eeb875e971842e8230338395367e08f.zip
fluxbox_pavel-075dc35b5eeb875e971842e8230338395367e08f.tar.bz2
updates from han to remove dependency on getopts, but still
provide argument-grouping functionality
Diffstat (limited to 'util')
-rwxr-xr-xutil/fluxbox-generate_menu105
1 files changed, 75 insertions, 30 deletions
diff --git a/util/fluxbox-generate_menu b/util/fluxbox-generate_menu
index cc1c986..1a5cabd 100755
--- a/util/fluxbox-generate_menu
+++ b/util/fluxbox-generate_menu
@@ -22,7 +22,7 @@
22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23# DEALINGS IN THE SOFTWARE. 23# DEALINGS IN THE SOFTWARE.
24# 24#
25# $Id: fluxbox-generate_menu,v 1.53 2003/09/29 11:59:35 fluxgen Exp $ 25# $Id: fluxbox-generate_menu,v 1.54 2003/10/08 14:18:25 rathnor Exp $
26 26
27# 27#
28# Portability notes: 28# Portability notes:
@@ -63,7 +63,7 @@ Options:
63 63
64 -k Insert a kde menu 64 -k Insert a kde menu
65 -g Add a gnome menu 65 -g Add a gnome menu
66 -B enable backgroundmenu 66 -B enable backgrounds menu
67 -r Don't remove empty menu-entries; for templates 67 -r Don't remove empty menu-entries; for templates
68 68
69 -t Favourite terminal 69 -t Favourite terminal
@@ -609,38 +609,83 @@ if [ ! "${INSTALL}" = Yes ]; then
609 609
610EOF 610EOF
611 else 611 else
612 echo "Warning: I could't create ${HOME}/.fluxbox/menuconfig" >&2 612 echo "Warning: I couldn't create ${HOME}/.fluxbox/menuconfig" >&2
613 fi 613 fi
614 fi 614 fi
615 fi 615 fi
616fi 616fi
617
618testoption() {
619 if [ -z "$3" -o -n "`echo $3|grep '^-'`" ]; then
620 echo "Error: The option $2 requires an argument." >&2
621 exit 1
622 fi
623 case $1 in
624 ex) # executable
625 if find_it "$3"; then
626 :
627 else
628 echo "Error: The option $2 needs an executable as argument, and \`$3' is not." >&2
629 fi
630 ;;
631 di) # directory
632 if [ -d "$3" ]; then
633 :
634 else
635 echo "Error: The option $2 needs a directory as argument, and \`$3' is not." >&2
636 fi
637 ;;
638 fl) # file
639 if [ -r "$3" ]; then
640 :
641 else
642 echo "Error: The option $2 needs a readable file as argument, and \`$3' is not." >&2
643 fi
644 ;;
645 sk) # skip
646 :
647 ;;
648 esac
649}
650
617# Get options. 651# Get options.
618while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do 652while [ $# -gt 0 ]; do
619 case "${COMMAND_LINE_ARGUMENT}" in 653 case "$1" in
620 B) BACKGROUNDMENUITEM=yes ;; 654 -B) BACKGROUNDMENUITEM=yes; shift;;
621 k) KDEMENU=yes ;; 655 -k) KDEMENU=yes; shift;;
622 g) GNOMEMENU=yes ;; 656 -g) GNOMEMENU=yes; shift;;
623 t) MY_TERM=${OPTARG} ;; 657 -t) MY_TERM=${2}; testoption ex $1 $2; shift 2;;
624 b) MY_BROWSER=${OPTARG} ;; 658 -b) MY_BROWSER=${2}; testoption ex $1 $2; shift 2;;
625 o) MENUFILENAME=${OPTARG} ;; 659 -o) MENUFILENAME=${2}; testoption fi $1 $2; shift 2;;
626 p) PREFIX=${OPTARG} ;; 660 -p) PREFIX=${2}; testoption di $1 $2; shift 2;;
627 n) GNOME_PREFIX=${OPTARG} ;; 661 -n) GNOME_PREFIX=${2}; testoption di $1 $2; shift 2;;
628 q) KDE_PREFIX=${OPTARG} ;; 662 -q) KDE_PREFIX=${2}; testoption di $1 $2; shift 2;;
629 m) MENUTITLE=${OPTARG} ;; 663 -m) MENUTITLE=${2}; testoption sk $1 $2; shift 2;;
630 w) HOMEPAGE=${OPTARG} ;; 664 -w) HOMEPAGE=${2}; testoption sk $1 $2; shift 2;;
631 u) USERMENU=${OPTARG} ;; 665 -u) USERMENU=${2}; testoption fl $1 $2; shift 2;;
632 r) REMOVE=no ;; 666 -r) REMOVE=no; shift;;
633 h) display_help ; exit 0 ;; 667 -h) display_help ; exit 0 ;;
634 a) display_authors ; exit 0 ;; 668 -a) display_authors ; exit 0 ;;
635 -) echo "fluxbox-generate_menu doesn't recognize -- gnu-longopts." 669 --*) echo "fluxbox-generate_menu doesn't recognize -- gnu-longopts."
636 echo 'Use fluxbox-generate_menu -h for a long help message.' 670 echo 'Use fluxbox-generate_menu -h for a long help message.'
637 display_usage 671 display_usage
638 exit 1 ;; 672 exit 1 ;;
639 *) echo 'Use fluxbox-generate_menu -h for a long help message.' 673 -[a-zA-Z][a-zA-Z]*)
640 display_usage 674 # split concatenated single-letter options apart
641 exit 1 ;; 675 FIRST="$1"; shift
642 esac 676 set -- `echo "$FIRST" | sed 's/^-\(.\)\(.*\)/-\1 -\2/'` "$@"
677 ;;
678 -*)
679 echo 1>&2 "fluxbox-generate_menu: unrecognized option "\`"$1'"
680 display_usage
681 exit 1
682 ;;
683 *)
684 break
685 ;;
686 esac
643done 687done
688
644# Check defaults 689# Check defaults
645 690
646# Can we actually create ${MENUFILENAME} 691# Can we actually create ${MENUFILENAME}
@@ -987,5 +1032,5 @@ if [ ! "${REMOVE}" ]; then
987 clean_up 1032 clean_up
988fi 1033fi
989 1034
990echo 'Menu succesfully generated.' 1035echo 'Menu successfully generated.'
991echo 'Use fluxbox-generate_menu -h to read all about the latest features.' 1036echo 'Use fluxbox-generate_menu -h to read about all the latest features.'