improve generation of kde and gnome menus in fluxbox-generate_menu

This commit is contained in:
rathnor 2003-08-02 14:26:45 +00:00
parent 7d5cb5887d
commit 933375f07a
3 changed files with 81 additions and 68 deletions

View file

@ -1,5 +1,8 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.5: Changes for 0.9.5:
*03/08/03:
* Improve inclusion of GNOME and KDE menus (Simon and Han)
fluxbox-generate_menu data/Makefile.am
*03/07/29: *03/07/29:
* Fixed kde dockapp bug (Henrik) * Fixed kde dockapp bug (Henrik)
Screen.cc, fluxbox.cc Screen.cc, fluxbox.cc

View file

@ -12,4 +12,4 @@ init: init.in
@regex_cmd@ -e "s,@pkgdatadir@,$(pkgdatadir),g" init.in > init @regex_cmd@ -e "s,@pkgdatadir@,$(pkgdatadir),g" init.in > init
menu: ../util/fluxbox-generate_menu menu: ../util/fluxbox-generate_menu
env FILENAME=menu PKGDATADIR="${prefix}/share" MENUTITLE="Fluxbox-${VERSION}" INSTALL=Yes ../util/fluxbox-generate_menu env FILENAME=menu PREFIX="${prefix}" MENUTITLE="Fluxbox-${VERSION}" INSTALL=Yes ../util/fluxbox-generate_menu

View file

@ -22,7 +22,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE. # DEALINGS IN THE SOFTWARE.
# #
# $Id: fluxbox-generate_menu,v 1.41 2003/07/29 09:29:45 fluxgen Exp $ # $Id: fluxbox-generate_menu,v 1.42 2003/08/02 14:26:45 rathnor Exp $
# #
# Portability notes: # Portability notes:
@ -58,10 +58,10 @@ Options:
-k Insert a kde menu -k Insert a kde menu
-g Add a gnome menu -g Add a gnome menu
-B enable backgroundmenu -B enable backgroundmenu
-r Don't remove empty menu-entries; for templates. -r Don't remove empty menu-entries; for templates
-t Favourite terminal -t Favourite terminal
-w Homepage for console-browsers. Default is fluxbox.org. -w Homepage for console-browsers. Default is fluxbox.org
-b Favourite browser -b Favourite browser
-m Menu-title; default is "Fluxbox" -m Menu-title; default is "Fluxbox"
-o Outputfile; default is ~/.fluxbox/menu -o Outputfile; default is ~/.fluxbox/menu
@ -72,9 +72,9 @@ Options:
Only for packagers: Only for packagers:
-p Package-datadir; /usr/local/share -p prefix; default is /usr/local
-n Gnome-datadir -n Gnome-prefix; /opt, /usr and /usr/local autodetected
-q KDE-datadir -q KDE-prefix; idem dito
Files: Files:
@ -141,8 +141,10 @@ append_menu_end() {
} }
menu_entry() { menu_entry() {
append "[exec] (`grep -v GenericName $* | grep Name= | cut -d = -f 2`) \ if [ -f "$1" ]; then
{`grep -v TryExec $* | grep Exec= | cut -d = -f 2`}" append "[exec] (`grep -v GenericName $* 2>/dev/null | grep Name= | cut -d = -f 2`) \
{`grep -v TryExec $* 2>/dev/null| grep Exec= | cut -d = -f 2`}"
fi
} }
menu_entry_dircheck() { menu_entry_dircheck() {
@ -152,11 +154,37 @@ menu_entry_dircheck() {
} }
menu_entry_dir() { menu_entry_dir() {
for b in `ls "$*"/*.desktop 2>/dev/null `; do for b in "$*"/*.desktop; do
menu_entry "${b}" menu_entry "${b}"
done done
} }
# recursively build a menu from the listed directories
# the dirs are merged
recurse_dir_menu () {
ls "$@"/ 2>/dev/null | sort | uniq | while read name; do
for dir in "$@"; do
if [ -n "$name" -a -d "$dir/$name" ]; then
# recurse
append_submenu "${name}"
# unfortunately, this is messy since we can't easily expand
# them all. Only allow for 3 atm. Add more if needed
recurse_dir_menu ${1:+"$1/$name"} ${2:+"$2/$name"} ${3:+"$3/$name"}
append_menu_end
break; # found one, it'll pick up all the rest
fi
# ignore it if it is a file, since menu_entry_dir picks those up
done
done
# Make entries for current dir after all submenus
for dir in "$@"; do
menu_entry_dircheck "${dir}"
done
}
normal_find() { normal_find() {
while [ "$1" ]; do while [ "$1" ]; do
find_it $1 append "[exec] ($1) {$1}" find_it $1 append "[exec] ($1) {$1}"
@ -537,24 +565,22 @@ if [ ! "${INSTALL}" = "Yes" ];then
# location with your own menu-entries # location with your own menu-entries
# USERMENU=~/.fluxbox/usermenu # USERMENU=~/.fluxbox/usermenu
# --- Datadirs
# These are datadirs; So if fluxbox data is installed in
# /usr/share/fluxbox
# your datadir is: /usr/share
# Data-dir # --- PREFIX'es
# PKGDATADIR=/usr/share # These are prefixes; So if fluxbox is installed in /usr/bin/fluxbox
# your prefix is: /usr
# fluxbox-generate already looks in /usr, /usr/local and /opt so there should be no need
# to specify them.
#
# PREFIX=/usr
# GNOME_PREFIX=/opt/gnome
# KDE_PREFIX=/opt/kde
# Gnome data-dir
# in case gnome is installed in another datadir.
# GPKGDATADIR=/opt/gnome/share
# Kde data-dir
# KPKGDATADIR=/opt/kde/share
# Sepparate the list of background-dirs with semicolumns ':' # Sepparate the list of background-dirs with semicolumns ':'
# BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:/usr/local/share/fluxbox/backgrounds/:/usr/share/wallpapers" # BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:/usr/local/share/fluxbox/backgrounds/:/usr/share/wallpapers"
# --- Boolean variables. # --- Boolean variables.
# Setting a variable to ``no'' won't help. Comment them out if you don't # Setting a variable to ``no'' won't help. Comment them out if you don't
# want them. Setting are overruled by the command-line options. # want them. Setting are overruled by the command-line options.
@ -587,9 +613,9 @@ while getopts ":Bkhragb:t:p:w:u:n:q:o:m:-:" COMMAND_LINE_ARGUMENT ; do
t) MY_TERM=${OPTARG} ;; t) MY_TERM=${OPTARG} ;;
b) MY_BROWSER=${OPTARG} ;; b) MY_BROWSER=${OPTARG} ;;
o) FILENAME=${OPTARG} ;; o) FILENAME=${OPTARG} ;;
p) PKGDATADIR=${OPTARG} ;; p) PREFIX=${OPTARG} ;;
n) GPKGDATADIR=${OPTARG} ;; n) GNOME_PREFIX=${OPTARG} ;;
q) KPKGDATADIR=${OPTARG} ;; q) KDE_PREFIX=${OPTARG} ;;
m) MENUTITLE=${OPTARG} ;; m) MENUTITLE=${OPTARG} ;;
w) HOMEPAGE=${OPTARG} ;; w) HOMEPAGE=${OPTARG} ;;
u) USERMENU=${OPTARG} ;; u) USERMENU=${OPTARG} ;;
@ -622,29 +648,30 @@ if [ -w "${FILENAME}" ]; then
mv ${FILENAME} ${FILENAME}.bak mv ${FILENAME} ${FILENAME}.bak
fi fi
# packagedatadir # prefix
PREFIX="${PREFIX:=@PREFIX@}" PREFIX="${PREFIX:=@PREFIX@}"
if [ ! -d "${PKGDATADIR}" -o -z "${PKGDATADIR}" ]; then if [ ! -d "${PREFIX}" -o -z "${PREFIX}" ]; then
if [ "$PREFIX" = '@PREFIX@' ]; then PREFIX=/usr/local
PKGDATADIR=/usr/local/share fi
else
PKGDATADIR=${PREFIX}/share # gnome prefix
for GNOME_PREFIX in "${GNOME_PREFIX}" /usr /opt /usr/local "${PREFIX}"; do
if [ -n "${GNOME_PREFIX}" -a -d "$GNOME_PREFIX/share/gnome" ]; then
break;
fi fi
fi done
# Will remain $PREFIX if all else fails
# gnome packagedatadir # kde prefix
if [ ! -d "${GPKGDATADIR}" -o -z "${GPKGDATADIR}" ]; then for KDE_PREFIX in "${KDE_PREFIX}" /usr /opt /usr/local "${PREFIX}"; do
GPKGDATADIR=${PKGDATADIR} if [ -n "${KDE_PREFIX}" -a -d "$KDE_PREFIX/share/applnk" ]; then
fi break;
fi
# kde packagedatadir done
if [ ! -d "${KPKGDATADIR}" -o -z "${KPKGDATADIR}" ]; then
KPKGDATADIR=${PKGDATADIR}
fi
# directory for the backgrounds # directory for the backgrounds
if [ -z "$BACKGROUND_DIRS" ]; then if [ -z "$BACKGROUND_DIRS" ]; then
BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:${PKGDATADIR}/fluxbox/backgrounds/" BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:${PREFIX}/share/fluxbox/backgrounds/"
fi fi
# find the default terminal # find the default terminal
@ -833,39 +860,22 @@ append_submenu "${GAMESMENU}"
find_it et append "[exec] (Enemy Territory) {et}" find_it et append "[exec] (Enemy Territory) {et}"
append_menu_end append_menu_end
# We'll only use this once
ETCAPPLNK=/etc/X11/applnk
# gnome menu # gnome menu
if [ -d ${GPKGDATADIR}/gnome/apps -a "${GNOMEMENU}" ]; then if [ -d "${GNOME_PREFIX}/share/gnome/apps" -a "${GNOMEMENU}" ]; then
append_submenu "${GNOMEMENUTEXT}" append_submenu "${GNOMEMENUTEXT}"
for a in `ls ${GPKGDATADIR}/gnome/apps/` ; do recurse_dir_menu "${GNOME_PREFIX}/share/gnome/apps" ${ETCAPPLNK}
if [ -d ${GPKGDATADIR}/gnome/apps/"${a}" ]; then
append_submenu "${a}"
menu_entry_dir "${GPKGDATADIR}/gnome/apps/${a}"
menu_entry_dircheck "/etc/X11/applnk/${a}"
append_menu_end
fi
done
append_menu_end append_menu_end
ETCAPPLNK=
fi fi
# kde submenu # kde submenu
if [ -d ${KPKGDATADIR}/applnk/ -a "${KDEMENU}" ]; then if [ -d "${KDE_PREFIX}/share/applnk/" -a "${KDEMENU}" ]; then
append_submenu "${KDEMENUTEXT}" append_submenu "${KDEMENUTEXT}"
for a in `ls ${KPKGDATADIR}/applnk/` ; do recurse_dir_menu "${KDE_PREFIX}/share/applnk" ${ETCAPPLNK}
if [ -d ${KPKGDATADIR}/applnk/"${a}" ]; then
append_submenu "${a}"
for x in ${KPKGDATADIR}/applnk/"${a}"/*; do
if [ -d ${KPKGDATADIR}/applnk/"${a}"/"${x}" ]; then
append_submenu "${x}"
menu_entry_dir ${KPKGDATADIR}/applnk/"${a}"/"${x}"
append_menu_end
fi
done
menu_entry_dir ${KPKGDATADIR}/applnk/"${a}"
append_menu_end
fi
done
menu_entry_dir ${KPKGDATADIR}/applnk/
append_menu_end append_menu_end
ETCAPPLNK=
fi fi
#User menu #User menu
@ -877,7 +887,7 @@ append_submenu "${FBSETTINGSMENU}"
append "[config] (${CONFIGUREMENU})" append "[config] (${CONFIGUREMENU})"
append_menu "[submenu] (${SYSTEMSTYLES}) {${STYLEMENUTITLE}}" append_menu "[submenu] (${SYSTEMSTYLES}) {${STYLEMENUTITLE}}"
append "[stylesdir] (${PKGDATADIR}/fluxbox/styles)" append "[stylesdir] (${PREFIX}/share/fluxbox/styles)"
append_menu_end append_menu_end
append_menu "[submenu] (${USERSTYLES}) {${STYLEMENUTITLE}}" append_menu "[submenu] (${USERSTYLES}) {${STYLEMENUTITLE}}"