diff options
author | rathnor <rathnor> | 2003-08-04 14:13:33 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-08-04 14:13:33 (GMT) |
commit | 14e9c6f80a4600a0d51134b321aa0c7779ebd7da (patch) | |
tree | e00c80b6bde6ccc0c2581b8fdf69038d5dcdbaa0 | |
parent | 301bd5c0aa879c12889ea76666e23d80649ab372 (diff) | |
download | fluxbox-14e9c6f80a4600a0d51134b321aa0c7779ebd7da.zip fluxbox-14e9c6f80a4600a0d51134b321aa0c7779ebd7da.tar.bz2 |
From Han:
- use MENUFILENAME instead of the vague FILENAME
- Cleanup some bullshit checks
- simpler wm-section
-rwxr-xr-x | util/fluxbox-generate_menu | 76 |
1 files changed, 32 insertions, 44 deletions
diff --git a/util/fluxbox-generate_menu b/util/fluxbox-generate_menu index 3a33157..b7215f1 100755 --- a/util/fluxbox-generate_menu +++ b/util/fluxbox-generate_menu | |||
@@ -22,13 +22,14 @@ | |||
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.46 2003/08/03 04:12:03 rathnor Exp $ | 25 | # $Id: fluxbox-generate_menu,v 1.47 2003/08/04 14:13:33 rathnor Exp $ |
26 | 26 | ||
27 | # | 27 | # |
28 | # Portability notes: | 28 | # Portability notes: |
29 | # To guarantee this script works on all platforms that support fluxbox | 29 | # To guarantee this script works on all platforms that support fluxbox |
30 | # please keep the following restrictions in mind: | 30 | # please keep the following restrictions in mind: |
31 | # | 31 | # |
32 | # don't use if ! command;, use command; if [ $? -ne 0 ]; | ||
32 | # don't use [ -e file ] use [ -r file ] | 33 | # don't use [ -e file ] use [ -r file ] |
33 | # don't use $(), use `` | 34 | # don't use $(), use `` |
34 | # don't use ~, use ${HOME} | 35 | # don't use ~, use ${HOME} |
@@ -123,21 +124,21 @@ case `uname` in | |||
123 | esac | 124 | esac |
124 | 125 | ||
125 | append() { | 126 | append() { |
126 | echo " $*" >> ${FILENAME} | 127 | echo " $*" >> ${MENUFILENAME} |
127 | } | 128 | } |
128 | 129 | ||
129 | append_menu() { | 130 | append_menu() { |
130 | echo "$*" >> ${FILENAME} | 131 | echo "$*" >> ${MENUFILENAME} |
131 | } | 132 | } |
132 | 133 | ||
133 | append_submenu() { | 134 | append_submenu() { |
134 | [ "${REMOVE}" ] && echo >> ${FILENAME} # only an empty line in templates | 135 | [ "${REMOVE}" ] && echo >> ${MENUFILENAME} # only an empty line in templates |
135 | append_menu "[submenu] ($1)" | 136 | append_menu "[submenu] ($1)" |
136 | } | 137 | } |
137 | 138 | ||
138 | append_menu_end() { | 139 | append_menu_end() { |
139 | append_menu "[end]" | 140 | append_menu "[end]" |
140 | [ "${REMOVE}" ] && echo >> ${FILENAME} # only an empty line in templates | 141 | [ "${REMOVE}" ] && echo >> ${MENUFILENAME} # only an empty line in templates |
141 | } | 142 | } |
142 | 143 | ||
143 | menu_entry() { | 144 | menu_entry() { |
@@ -194,11 +195,11 @@ normal_find() { | |||
194 | 195 | ||
195 | clean_up() { | 196 | clean_up() { |
196 | # -e "/^$/d" -e "/^$/d" | 197 | # -e "/^$/d" -e "/^$/d" |
197 | cat ${FILENAME} | sed -e "/^\[submenu]/{ | 198 | cat ${MENUFILENAME} | sed -e "/^\[submenu]/{ |
198 | N | 199 | N |
199 | /^\[submenu].*\n\[end]/d | 200 | /^\[submenu].*\n\[end]/d |
200 | }" > ${FILENAME}.tmp | 201 | }" > ${MENUFILENAME}.tmp |
201 | mv -f ${FILENAME}.tmp ${FILENAME} | 202 | mv -f ${MENUFILENAME}.tmp ${MENUFILENAME} |
202 | } | 203 | } |
203 | 204 | ||
204 | # menu defaults (if translation forget to set one of them) | 205 | # menu defaults (if translation forget to set one of them) |
@@ -530,7 +531,7 @@ case ${LC_ALL} in | |||
530 | esac | 531 | esac |
531 | 532 | ||
532 | # Set Defaults | 533 | # Set Defaults |
533 | FILENAME="${FILENAME:=${HOME}/.fluxbox/menu}" | 534 | MENUFILENAME="${MENUFILENAME:=${HOME}/.fluxbox/menu}" |
534 | MENUTITLE="${MENUTITLE:=Fluxbox}" | 535 | MENUTITLE="${MENUTITLE:=Fluxbox}" |
535 | HOMEPAGE="${HOMEPAGE:=fluxbox.org}" | 536 | HOMEPAGE="${HOMEPAGE:=fluxbox.org}" |
536 | USERMENU="${USERMENU:=${HOME}/.fluxbox/usermenu}" | 537 | USERMENU="${USERMENU:=${HOME}/.fluxbox/usermenu}" |
@@ -555,7 +556,7 @@ if [ ! "${INSTALL}" = "Yes" ];then | |||
555 | # MY_BROWSER=mozilla | 556 | # MY_BROWSER=mozilla |
556 | 557 | ||
557 | # Name of the outputfile | 558 | # Name of the outputfile |
558 | # FILENAME=${HOME}/.fluxbox/menu | 559 | # MENUFILENAME=${HOME}/.fluxbox/menu |
559 | 560 | ||
560 | # MENUTITLE=\`fluxbox -version|cut -d " " -f-2\` | 561 | # MENUTITLE=\`fluxbox -version|cut -d " " -f-2\` |
561 | 562 | ||
@@ -612,7 +613,7 @@ while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do | |||
612 | g) GNOMEMENU=yes ;; | 613 | g) GNOMEMENU=yes ;; |
613 | t) MY_TERM=${OPTARG} ;; | 614 | t) MY_TERM=${OPTARG} ;; |
614 | b) MY_BROWSER=${OPTARG} ;; | 615 | b) MY_BROWSER=${OPTARG} ;; |
615 | o) FILENAME=${OPTARG} ;; | 616 | o) MENUFILENAME=${OPTARG} ;; |
616 | p) PREFIX=${OPTARG} ;; | 617 | p) PREFIX=${OPTARG} ;; |
617 | n) GNOME_PREFIX=${OPTARG} ;; | 618 | n) GNOME_PREFIX=${OPTARG} ;; |
618 | q) KDE_PREFIX=${OPTARG} ;; | 619 | q) KDE_PREFIX=${OPTARG} ;; |
@@ -633,19 +634,19 @@ while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do | |||
633 | done | 634 | done |
634 | # Check defaults | 635 | # Check defaults |
635 | 636 | ||
636 | # Can we actually create ${FILENAME} | 637 | # Can we actually create ${MENUFILENAME} |
637 | touch ${FILENAME} 2> /dev/null | 638 | touch ${MENUFILENAME} 2>/dev/null |
638 | if [ $? -ne 0 ]; then | 639 | if [ $? -ne 0 ]; then |
639 | echo "Fatal error: can't create $FILENAME" >&2 | 640 | echo "Fatal error: can't create or write to $MENUFILENAME" >&2 |
640 | exit 1 | 641 | exit 1 |
641 | fi | 642 | fi |
642 | 643 | ||
643 | # backup menu | 644 | # backup menu |
644 | if [ -w "${FILENAME}" ]; then | 645 | if [ -w "${MENUFILENAME}" ]; then |
645 | if [ -f ${FILENAME}.firstbak ]; then | 646 | if [ -f ${MENUFILENAME}.firstbak ]; then |
646 | cp ${FILENAME} ${FILENAME}.firstbak | 647 | cp ${MENUFILENAME} ${MENUFILENAME}.firstbak |
647 | fi | 648 | fi |
648 | mv ${FILENAME} ${FILENAME}.bak | 649 | mv ${MENUFILENAME} ${MENUFILENAME}.bak |
649 | fi | 650 | fi |
650 | 651 | ||
651 | # prefix | 652 | # prefix |
@@ -677,7 +678,7 @@ fi | |||
677 | # find the default terminal | 678 | # find the default terminal |
678 | find_it $MY_TERM | 679 | find_it $MY_TERM |
679 | if [ $? -ne 0 ]; then | 680 | if [ $? -ne 0 ]; then |
680 | [ -n "$MY_TERM" ] && echo "Warning: you chose an invalid term." >&2 | 681 | echo "Warning: you chose an invalid term." >&2 |
681 | #The precise order is up for debate. | 682 | #The precise order is up for debate. |
682 | for term in Eterm aterm rxvt wterm xterm konsole gnome-terminal; do | 683 | for term in Eterm aterm rxvt wterm xterm konsole gnome-terminal; do |
683 | if find_it $term; then | 684 | if find_it $term; then |
@@ -692,8 +693,8 @@ fi | |||
692 | 693 | ||
693 | # find the default browser | 694 | # find the default browser |
694 | find_it $MY_BROWSER | 695 | find_it $MY_BROWSER |
695 | if [ $? -ne 0 ]; then | 696 | if [ $? -ne 0]; then |
696 | [ -n "$MY_BROWSER" ] && echo "Warning: you chose an invalid browser." >&2 | 697 | echo "Warning: you chose an invalid browser." >&2 |
697 | #The precise order is up for debate. | 698 | #The precise order is up for debate. |
698 | for browser in MozillaFirebird firebird opera skipstone phoenix mozilla galeon konqueror dillo netscape links w3m lynx; do | 699 | for browser in MozillaFirebird firebird opera skipstone phoenix mozilla galeon konqueror dillo netscape links w3m lynx; do |
699 | if find_it $browser; then | 700 | if find_it $browser; then |
@@ -716,7 +717,7 @@ fi | |||
716 | 717 | ||
717 | 718 | ||
718 | # Start of menu | 719 | # Start of menu |
719 | cat << EOF > ${FILENAME} | 720 | cat << EOF > ${MENUFILENAME} |
720 | # Generated by fluxbox-generate_menu | 721 | # Generated by fluxbox-generate_menu |
721 | # | 722 | # |
722 | # If you read this it means you want to edit this file manually, so here | 723 | # If you read this it means you want to edit this file manually, so here |
@@ -736,7 +737,7 @@ cat << EOF > ${FILENAME} | |||
736 | 737 | ||
737 | EOF | 738 | EOF |
738 | 739 | ||
739 | echo "[begin] (${MENUTITLE})" >> ${FILENAME} | 740 | echo "[begin] (${MENUTITLE})" >> ${MENUFILENAME} |
740 | 741 | ||
741 | 742 | ||
742 | append "[exec] (${DEFAULT_TERM}) {${DEFAULT_TERM}}" | 743 | append "[exec] (${DEFAULT_TERM}) {${DEFAULT_TERM}}" |
@@ -856,7 +857,7 @@ append_submenu "${GAMESMENU}" | |||
856 | gnect mahjongg gnomine gnome-stones gnometris gnotravex \ | 857 | gnect mahjongg gnomine gnome-stones gnometris gnotravex \ |
857 | gnotski iagno knights eboard xboard freecell pysol \ | 858 | gnotski iagno knights eboard xboard freecell pysol \ |
858 | gtali tuxracer xpenguins xsnow xeyes xpenguins \ | 859 | gtali tuxracer xpenguins xsnow xeyes xpenguins \ |
859 | quake2 quake3 skoosh same-gnome enigma xbill | 860 | quake2 quake3 skoosh same-gnome enigma xbill icebreaker |
860 | find_it et append "[exec] (Enemy Territory) {et}" | 861 | find_it et append "[exec] (Enemy Territory) {et}" |
861 | append_menu_end | 862 | append_menu_end |
862 | 863 | ||
@@ -880,7 +881,7 @@ fi | |||
880 | 881 | ||
881 | #User menu | 882 | #User menu |
882 | if [ -r "${USERMENU}" ]; then | 883 | if [ -r "${USERMENU}" ]; then |
883 | cat ${USERMENU} >> ${FILENAME} | 884 | cat ${USERMENU} >> ${MENUFILENAME} |
884 | fi | 885 | fi |
885 | 886 | ||
886 | append_submenu "${FBSETTINGSMENU}" | 887 | append_submenu "${FBSETTINGSMENU}" |
@@ -948,29 +949,16 @@ append_submenu "${FBSETTINGSMENU}" | |||
948 | append_menu_end | 949 | append_menu_end |
949 | 950 | ||
950 | append_submenu ${WINDOWMANAGERS} | 951 | append_submenu ${WINDOWMANAGERS} |
951 | find_it starticewm append "[restart] (icewm) {starticewm}" ||\ | 952 | #hard to properly maintain since there are so many exceptions to the rule. |
952 | find_it icewm append "[restart] (icewm) {icewm}" | 953 | for wm in icewm ion kde sawfish enlightenment openbox evilwm waimea xfce pekwm;do |
953 | find_it ion append "[restart] (ion) {ion}" | 954 | find_it start${wm} append "[restart] (${wm}) {start${wm}}" ||\ |
954 | find_it startkde append "[restart] (kde) {startkde}" | 955 | find_it ${wm} append "[restart] (${wm}) {${wm}}" |
955 | find_it startsawfish append "[restart] (sawfish) {startsawfish}" ||\ | 956 | done |
956 | find_it sawfish append "[restart] (sawfish) {sawfish}" | ||
957 | find_it startgnome append "[restart] (gnome) {startgnome}" ||\ | 957 | find_it startgnome append "[restart] (gnome) {startgnome}" ||\ |
958 | find_it gnome-session append "[restart] (gnome) {gnome-session}" | 958 | find_it gnome-session append "[restart] (gnome) {gnome-session}" |
959 | |||
959 | find_it startwindowmaker append "[restart] (windowmaker) {startwindowmaker}" ||\ | 960 | find_it startwindowmaker append "[restart] (windowmaker) {startwindowmaker}" ||\ |
960 | find_it wmaker append "[restart] (windowmaker) {wmaker}" | 961 | find_it wmaker append "[restart] (windowmaker) {wmaker}" |
961 | find_it startenlightenment append "[restart] (enlightenment) {startenlightenment}" ||\ | ||
962 | find_it enlightenment append "[restart] (enlightenment) {enlightenment}" | ||
963 | find_it startafterstep append "[restart] (afterstep) {startafterstep}" ||\ | ||
964 | find_it afterstep append "[restart] (afterstep) {afterstep}" | ||
965 | find_it startopenbox append "[restart] (openbox) {startopenbox}" ||\ | ||
966 | find_it openbox append "[restart] (openbox) {openbox}" | ||
967 | find_it startevilwm append "[restart] (evilwm) {startevilwm}" ||\ | ||
968 | find_it evilwm append "[restart] (evilwm) {evilwm}" | ||
969 | find_it startwaimea append "[restart] (waimea) {startwaimea}" ||\ | ||
970 | find_it waimea append "[restart] (waimea) {waimea}" | ||
971 | find_it startxfce append "[restart] (xfce) {startxfce}" | ||
972 | find_it startpekwm append "[restart] (pekwm) {startpekwm}" ||\ | ||
973 | find_it pekwm append "[restart] (pekwm) {pekwm}" | ||
974 | append_menu_end | 962 | append_menu_end |
975 | 963 | ||
976 | append "[reconfig] (${RELOADITEM})" | 964 | append "[reconfig] (${RELOADITEM})" |