From Han:
- use MENUFILENAME instead of the vague FILENAME - Cleanup some bullshit checks - simpler wm-section
This commit is contained in:
parent
301bd5c0aa
commit
14e9c6f80a
1 changed files with 32 additions and 44 deletions
|
@ -22,13 +22,14 @@
|
|||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
# DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# $Id: fluxbox-generate_menu,v 1.46 2003/08/03 04:12:03 rathnor Exp $
|
||||
# $Id: fluxbox-generate_menu,v 1.47 2003/08/04 14:13:33 rathnor Exp $
|
||||
|
||||
#
|
||||
# Portability notes:
|
||||
# To guarantee this script works on all platforms that support fluxbox
|
||||
# please keep the following restrictions in mind:
|
||||
#
|
||||
# don't use if ! command;, use command; if [ $? -ne 0 ];
|
||||
# don't use [ -e file ] use [ -r file ]
|
||||
# don't use $(), use ``
|
||||
# don't use ~, use ${HOME}
|
||||
|
@ -123,21 +124,21 @@ case `uname` in
|
|||
esac
|
||||
|
||||
append() {
|
||||
echo " $*" >> ${FILENAME}
|
||||
echo " $*" >> ${MENUFILENAME}
|
||||
}
|
||||
|
||||
append_menu() {
|
||||
echo "$*" >> ${FILENAME}
|
||||
echo "$*" >> ${MENUFILENAME}
|
||||
}
|
||||
|
||||
append_submenu() {
|
||||
[ "${REMOVE}" ] && echo >> ${FILENAME} # only an empty line in templates
|
||||
[ "${REMOVE}" ] && echo >> ${MENUFILENAME} # only an empty line in templates
|
||||
append_menu "[submenu] ($1)"
|
||||
}
|
||||
|
||||
append_menu_end() {
|
||||
append_menu "[end]"
|
||||
[ "${REMOVE}" ] && echo >> ${FILENAME} # only an empty line in templates
|
||||
[ "${REMOVE}" ] && echo >> ${MENUFILENAME} # only an empty line in templates
|
||||
}
|
||||
|
||||
menu_entry() {
|
||||
|
@ -194,11 +195,11 @@ normal_find() {
|
|||
|
||||
clean_up() {
|
||||
# -e "/^$/d" -e "/^$/d"
|
||||
cat ${FILENAME} | sed -e "/^\[submenu]/{
|
||||
cat ${MENUFILENAME} | sed -e "/^\[submenu]/{
|
||||
N
|
||||
/^\[submenu].*\n\[end]/d
|
||||
}" > ${FILENAME}.tmp
|
||||
mv -f ${FILENAME}.tmp ${FILENAME}
|
||||
}" > ${MENUFILENAME}.tmp
|
||||
mv -f ${MENUFILENAME}.tmp ${MENUFILENAME}
|
||||
}
|
||||
|
||||
# menu defaults (if translation forget to set one of them)
|
||||
|
@ -530,7 +531,7 @@ case ${LC_ALL} in
|
|||
esac
|
||||
|
||||
# Set Defaults
|
||||
FILENAME="${FILENAME:=${HOME}/.fluxbox/menu}"
|
||||
MENUFILENAME="${MENUFILENAME:=${HOME}/.fluxbox/menu}"
|
||||
MENUTITLE="${MENUTITLE:=Fluxbox}"
|
||||
HOMEPAGE="${HOMEPAGE:=fluxbox.org}"
|
||||
USERMENU="${USERMENU:=${HOME}/.fluxbox/usermenu}"
|
||||
|
@ -555,7 +556,7 @@ if [ ! "${INSTALL}" = "Yes" ];then
|
|||
# MY_BROWSER=mozilla
|
||||
|
||||
# Name of the outputfile
|
||||
# FILENAME=${HOME}/.fluxbox/menu
|
||||
# MENUFILENAME=${HOME}/.fluxbox/menu
|
||||
|
||||
# MENUTITLE=\`fluxbox -version|cut -d " " -f-2\`
|
||||
|
||||
|
@ -612,7 +613,7 @@ while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do
|
|||
g) GNOMEMENU=yes ;;
|
||||
t) MY_TERM=${OPTARG} ;;
|
||||
b) MY_BROWSER=${OPTARG} ;;
|
||||
o) FILENAME=${OPTARG} ;;
|
||||
o) MENUFILENAME=${OPTARG} ;;
|
||||
p) PREFIX=${OPTARG} ;;
|
||||
n) GNOME_PREFIX=${OPTARG} ;;
|
||||
q) KDE_PREFIX=${OPTARG} ;;
|
||||
|
@ -633,19 +634,19 @@ while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do
|
|||
done
|
||||
# Check defaults
|
||||
|
||||
# Can we actually create ${FILENAME}
|
||||
touch ${FILENAME} 2> /dev/null
|
||||
# Can we actually create ${MENUFILENAME}
|
||||
touch ${MENUFILENAME} 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Fatal error: can't create $FILENAME" >&2
|
||||
echo "Fatal error: can't create or write to $MENUFILENAME" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# backup menu
|
||||
if [ -w "${FILENAME}" ]; then
|
||||
if [ -f ${FILENAME}.firstbak ]; then
|
||||
cp ${FILENAME} ${FILENAME}.firstbak
|
||||
if [ -w "${MENUFILENAME}" ]; then
|
||||
if [ -f ${MENUFILENAME}.firstbak ]; then
|
||||
cp ${MENUFILENAME} ${MENUFILENAME}.firstbak
|
||||
fi
|
||||
mv ${FILENAME} ${FILENAME}.bak
|
||||
mv ${MENUFILENAME} ${MENUFILENAME}.bak
|
||||
fi
|
||||
|
||||
# prefix
|
||||
|
@ -677,7 +678,7 @@ fi
|
|||
# find the default terminal
|
||||
find_it $MY_TERM
|
||||
if [ $? -ne 0 ]; then
|
||||
[ -n "$MY_TERM" ] && echo "Warning: you chose an invalid term." >&2
|
||||
echo "Warning: you chose 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
|
||||
|
@ -693,7 +694,7 @@ fi
|
|||
# find the default browser
|
||||
find_it $MY_BROWSER
|
||||
if [ $? -ne 0]; then
|
||||
[ -n "$MY_BROWSER" ] && echo "Warning: you chose an invalid browser." >&2
|
||||
echo "Warning: you chose an invalid browser." >&2
|
||||
#The precise order is up for debate.
|
||||
for browser in MozillaFirebird firebird opera skipstone phoenix mozilla galeon konqueror dillo netscape links w3m lynx; do
|
||||
if find_it $browser; then
|
||||
|
@ -716,7 +717,7 @@ fi
|
|||
|
||||
|
||||
# Start of menu
|
||||
cat << EOF > ${FILENAME}
|
||||
cat << EOF > ${MENUFILENAME}
|
||||
# Generated by fluxbox-generate_menu
|
||||
#
|
||||
# If you read this it means you want to edit this file manually, so here
|
||||
|
@ -736,7 +737,7 @@ cat << EOF > ${FILENAME}
|
|||
|
||||
EOF
|
||||
|
||||
echo "[begin] (${MENUTITLE})" >> ${FILENAME}
|
||||
echo "[begin] (${MENUTITLE})" >> ${MENUFILENAME}
|
||||
|
||||
|
||||
append "[exec] (${DEFAULT_TERM}) {${DEFAULT_TERM}}"
|
||||
|
@ -856,7 +857,7 @@ append_submenu "${GAMESMENU}"
|
|||
gnect mahjongg gnomine gnome-stones gnometris gnotravex \
|
||||
gnotski iagno knights eboard xboard freecell pysol \
|
||||
gtali tuxracer xpenguins xsnow xeyes xpenguins \
|
||||
quake2 quake3 skoosh same-gnome enigma xbill
|
||||
quake2 quake3 skoosh same-gnome enigma xbill icebreaker
|
||||
find_it et append "[exec] (Enemy Territory) {et}"
|
||||
append_menu_end
|
||||
|
||||
|
@ -880,7 +881,7 @@ fi
|
|||
|
||||
#User menu
|
||||
if [ -r "${USERMENU}" ]; then
|
||||
cat ${USERMENU} >> ${FILENAME}
|
||||
cat ${USERMENU} >> ${MENUFILENAME}
|
||||
fi
|
||||
|
||||
append_submenu "${FBSETTINGSMENU}"
|
||||
|
@ -948,29 +949,16 @@ append_submenu "${FBSETTINGSMENU}"
|
|||
append_menu_end
|
||||
|
||||
append_submenu ${WINDOWMANAGERS}
|
||||
find_it starticewm append "[restart] (icewm) {starticewm}" ||\
|
||||
find_it icewm append "[restart] (icewm) {icewm}"
|
||||
find_it ion append "[restart] (ion) {ion}"
|
||||
find_it startkde append "[restart] (kde) {startkde}"
|
||||
find_it startsawfish append "[restart] (sawfish) {startsawfish}" ||\
|
||||
find_it sawfish append "[restart] (sawfish) {sawfish}"
|
||||
#hard to properly maintain since there are so many exceptions to the rule.
|
||||
for wm in icewm ion kde sawfish enlightenment openbox evilwm waimea xfce pekwm;do
|
||||
find_it start${wm} append "[restart] (${wm}) {start${wm}}" ||\
|
||||
find_it ${wm} append "[restart] (${wm}) {${wm}}"
|
||||
done
|
||||
find_it startgnome append "[restart] (gnome) {startgnome}" ||\
|
||||
find_it gnome-session append "[restart] (gnome) {gnome-session}"
|
||||
|
||||
find_it startwindowmaker append "[restart] (windowmaker) {startwindowmaker}" ||\
|
||||
find_it wmaker append "[restart] (windowmaker) {wmaker}"
|
||||
find_it startenlightenment append "[restart] (enlightenment) {startenlightenment}" ||\
|
||||
find_it enlightenment append "[restart] (enlightenment) {enlightenment}"
|
||||
find_it startafterstep append "[restart] (afterstep) {startafterstep}" ||\
|
||||
find_it afterstep append "[restart] (afterstep) {afterstep}"
|
||||
find_it startopenbox append "[restart] (openbox) {startopenbox}" ||\
|
||||
find_it openbox append "[restart] (openbox) {openbox}"
|
||||
find_it startevilwm append "[restart] (evilwm) {startevilwm}" ||\
|
||||
find_it evilwm append "[restart] (evilwm) {evilwm}"
|
||||
find_it startwaimea append "[restart] (waimea) {startwaimea}" ||\
|
||||
find_it waimea append "[restart] (waimea) {waimea}"
|
||||
find_it startxfce append "[restart] (xfce) {startxfce}"
|
||||
find_it startpekwm append "[restart] (pekwm) {startpekwm}" ||\
|
||||
find_it pekwm append "[restart] (pekwm) {pekwm}"
|
||||
append_menu_end
|
||||
|
||||
append "[reconfig] (${RELOADITEM})"
|
||||
|
|
Loading…
Reference in a new issue