diff options
author | rathnor <rathnor> | 2003-10-08 14:18:25 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-10-08 14:18:25 (GMT) |
commit | 075dc35b5eeb875e971842e8230338395367e08f (patch) | |
tree | 448fa41227a09d1b774ec06e17c1632d4edffd86 | |
parent | ae729342e964c7b6d3571884b55ce14ff27fa553 (diff) | |
download | fluxbox_paul-075dc35b5eeb875e971842e8230338395367e08f.zip fluxbox_paul-075dc35b5eeb875e971842e8230338395367e08f.tar.bz2 |
updates from han to remove dependency on getopts, but still
provide argument-grouping functionality
-rw-r--r-- | ChangeLog | 3 | ||||
-rwxr-xr-x | util/fluxbox-generate_menu | 105 |
2 files changed, 78 insertions, 30 deletions
@@ -1,6 +1,9 @@ | |||
1 | (Format: Year/Month/Day) | 1 | (Format: Year/Month/Day) |
2 | Changes for 0.9.6: | 2 | Changes for 0.9.6: |
3 | *03/10/08: | 3 | *03/10/08: |
4 | * fluxbox-generate_menu update from Han | ||
5 | - replace getopts with portable workaround | ||
6 | fluxbox-generate_menu | ||
4 | * fbsetbg updates from Han, and some tweaking (Simon) | 7 | * fbsetbg updates from Han, and some tweaking (Simon) |
5 | fbsetbg | 8 | fbsetbg |
6 | *03/10/06: | 9 | *03/10/06: |
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 | ||
610 | EOF | 610 | EOF |
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 |
616 | fi | 616 | fi |
617 | |||
618 | testoption() { | ||
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. |
618 | while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do | 652 | while [ $# -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 | ||
643 | done | 687 | done |
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 |
988 | fi | 1033 | fi |
989 | 1034 | ||
990 | echo 'Menu succesfully generated.' | 1035 | echo 'Menu successfully generated.' |
991 | echo 'Use fluxbox-generate_menu -h to read all about the latest features.' | 1036 | echo 'Use fluxbox-generate_menu -h to read about all the latest features.' |