aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-08-02 14:26:45 (GMT)
committerrathnor <rathnor>2003-08-02 14:26:45 (GMT)
commit933375f07a4617857b9b4eae2c3a4f26a6e982b6 (patch)
tree17fc2cb22938ccf1ec17dfd7dbb83523d0a9d754
parent7d5cb5887d2898f5ca2f3ef5c998943edf12d100 (diff)
downloadfluxbox_paul-933375f07a4617857b9b4eae2c3a4f26a6e982b6.zip
fluxbox_paul-933375f07a4617857b9b4eae2c3a4f26a6e982b6.tar.bz2
improve generation of kde and gnome menus in fluxbox-generate_menu
-rw-r--r--ChangeLog3
-rw-r--r--data/Makefile.am2
-rwxr-xr-xutil/fluxbox-generate_menu142
3 files changed, 80 insertions, 67 deletions
diff --git a/ChangeLog b/ChangeLog
index 4418855..85af84d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.5: 2Changes for 0.9.5:
3*03/08/03:
4 * Improve inclusion of GNOME and KDE menus (Simon and Han)
5 fluxbox-generate_menu data/Makefile.am
3*03/07/29: 6*03/07/29:
4 * Fixed kde dockapp bug (Henrik) 7 * Fixed kde dockapp bug (Henrik)
5 Screen.cc, fluxbox.cc 8 Screen.cc, fluxbox.cc
diff --git a/data/Makefile.am b/data/Makefile.am
index e9d86f7..cafd1eb 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -12,4 +12,4 @@ init: init.in
12 @regex_cmd@ -e "s,@pkgdatadir@,$(pkgdatadir),g" init.in > init 12 @regex_cmd@ -e "s,@pkgdatadir@,$(pkgdatadir),g" init.in > init
13 13
14menu: ../util/fluxbox-generate_menu 14menu: ../util/fluxbox-generate_menu
15 env FILENAME=menu PKGDATADIR="${prefix}/share" MENUTITLE="Fluxbox-${VERSION}" INSTALL=Yes ../util/fluxbox-generate_menu 15 env FILENAME=menu PREFIX="${prefix}" MENUTITLE="Fluxbox-${VERSION}" INSTALL=Yes ../util/fluxbox-generate_menu
diff --git a/util/fluxbox-generate_menu b/util/fluxbox-generate_menu
index 7ba20dc..1a92180 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.41 2003/07/29 09:29:45 fluxgen Exp $ 25# $Id: fluxbox-generate_menu,v 1.42 2003/08/02 14:26:45 rathnor Exp $
26 26
27# 27#
28# Portability notes: 28# Portability notes:
@@ -58,10 +58,10 @@ Options:
58 -k Insert a kde menu 58 -k Insert a kde menu
59 -g Add a gnome menu 59 -g Add a gnome menu
60 -B enable backgroundmenu 60 -B enable backgroundmenu
61 -r Don't remove empty menu-entries; for templates. 61 -r Don't remove empty menu-entries; for templates
62 62
63 -t Favourite terminal 63 -t Favourite terminal
64 -w Homepage for console-browsers. Default is fluxbox.org. 64 -w Homepage for console-browsers. Default is fluxbox.org
65 -b Favourite browser 65 -b Favourite browser
66 -m Menu-title; default is "Fluxbox" 66 -m Menu-title; default is "Fluxbox"
67 -o Outputfile; default is ~/.fluxbox/menu 67 -o Outputfile; default is ~/.fluxbox/menu
@@ -72,9 +72,9 @@ Options:
72 72
73 Only for packagers: 73 Only for packagers:
74 74
75 -p Package-datadir; /usr/local/share 75 -p prefix; default is /usr/local
76 -n Gnome-datadir 76 -n Gnome-prefix; /opt, /usr and /usr/local autodetected
77 -q KDE-datadir 77 -q KDE-prefix; idem dito
78 78
79 79
80Files: 80Files:
@@ -141,8 +141,10 @@ append_menu_end() {
141} 141}
142 142
143menu_entry() { 143menu_entry() {
144 append "[exec] (`grep -v GenericName $* | grep Name= | cut -d = -f 2`) \ 144 if [ -f "$1" ]; then
145 {`grep -v TryExec $* | grep Exec= | cut -d = -f 2`}" 145 append "[exec] (`grep -v GenericName $* 2>/dev/null | grep Name= | cut -d = -f 2`) \
146 {`grep -v TryExec $* 2>/dev/null| grep Exec= | cut -d = -f 2`}"
147 fi
146} 148}
147 149
148menu_entry_dircheck() { 150menu_entry_dircheck() {
@@ -152,11 +154,37 @@ menu_entry_dircheck() {
152} 154}
153 155
154menu_entry_dir() { 156menu_entry_dir() {
155 for b in `ls "$*"/*.desktop 2>/dev/null `; do 157 for b in "$*"/*.desktop; do
156 menu_entry "${b}" 158 menu_entry "${b}"
157 done 159 done
158} 160}
159 161
162
163# recursively build a menu from the listed directories
164# the dirs are merged
165recurse_dir_menu () {
166 ls "$@"/ 2>/dev/null | sort | uniq | while read name; do
167 for dir in "$@"; do
168 if [ -n "$name" -a -d "$dir/$name" ]; then
169 # recurse
170 append_submenu "${name}"
171 # unfortunately, this is messy since we can't easily expand
172 # them all. Only allow for 3 atm. Add more if needed
173 recurse_dir_menu ${1:+"$1/$name"} ${2:+"$2/$name"} ${3:+"$3/$name"}
174 append_menu_end
175 break; # found one, it'll pick up all the rest
176 fi
177 # ignore it if it is a file, since menu_entry_dir picks those up
178 done
179 done
180
181 # Make entries for current dir after all submenus
182 for dir in "$@"; do
183 menu_entry_dircheck "${dir}"
184 done
185}
186
187
160normal_find() { 188normal_find() {
161 while [ "$1" ]; do 189 while [ "$1" ]; do
162 find_it $1 append "[exec] ($1) {$1}" 190 find_it $1 append "[exec] ($1) {$1}"
@@ -537,24 +565,22 @@ if [ ! "${INSTALL}" = "Yes" ];then
537# location with your own menu-entries 565# location with your own menu-entries
538# USERMENU=~/.fluxbox/usermenu 566# USERMENU=~/.fluxbox/usermenu
539 567
540# --- Datadirs
541# These are datadirs; So if fluxbox data is installed in
542# /usr/share/fluxbox
543# your datadir is: /usr/share
544
545# Data-dir
546# PKGDATADIR=/usr/share
547 568
548# Gnome data-dir 569# --- PREFIX'es
549# in case gnome is installed in another datadir. 570# These are prefixes; So if fluxbox is installed in /usr/bin/fluxbox
550# GPKGDATADIR=/opt/gnome/share 571# your prefix is: /usr
572# fluxbox-generate already looks in /usr, /usr/local and /opt so there should be no need
573# to specify them.
574#
575# PREFIX=/usr
576# GNOME_PREFIX=/opt/gnome
577# KDE_PREFIX=/opt/kde
551 578
552# Kde data-dir
553# KPKGDATADIR=/opt/kde/share
554 579
555# Sepparate the list of background-dirs with semicolumns ':' 580# Sepparate the list of background-dirs with semicolumns ':'
556# BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:/usr/local/share/fluxbox/backgrounds/:/usr/share/wallpapers" 581# BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:/usr/local/share/fluxbox/backgrounds/:/usr/share/wallpapers"
557 582
583
558# --- Boolean variables. 584# --- Boolean variables.
559# Setting a variable to ``no'' won't help. Comment them out if you don't 585# Setting a variable to ``no'' won't help. Comment them out if you don't
560# want them. Setting are overruled by the command-line options. 586# 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
587 t) MY_TERM=${OPTARG} ;; 613 t) MY_TERM=${OPTARG} ;;
588 b) MY_BROWSER=${OPTARG} ;; 614 b) MY_BROWSER=${OPTARG} ;;
589 o) FILENAME=${OPTARG} ;; 615 o) FILENAME=${OPTARG} ;;
590 p) PKGDATADIR=${OPTARG} ;; 616 p) PREFIX=${OPTARG} ;;
591 n) GPKGDATADIR=${OPTARG} ;; 617 n) GNOME_PREFIX=${OPTARG} ;;
592 q) KPKGDATADIR=${OPTARG} ;; 618 q) KDE_PREFIX=${OPTARG} ;;
593 m) MENUTITLE=${OPTARG} ;; 619 m) MENUTITLE=${OPTARG} ;;
594 w) HOMEPAGE=${OPTARG} ;; 620 w) HOMEPAGE=${OPTARG} ;;
595 u) USERMENU=${OPTARG} ;; 621 u) USERMENU=${OPTARG} ;;
@@ -622,29 +648,30 @@ if [ -w "${FILENAME}" ]; then
622 mv ${FILENAME} ${FILENAME}.bak 648 mv ${FILENAME} ${FILENAME}.bak
623fi 649fi
624 650
625# packagedatadir 651# prefix
626PREFIX="${PREFIX:=@PREFIX@}" 652PREFIX="${PREFIX:=@PREFIX@}"
627if [ ! -d "${PKGDATADIR}" -o -z "${PKGDATADIR}" ]; then 653if [ ! -d "${PREFIX}" -o -z "${PREFIX}" ]; then
628 if [ "$PREFIX" = '@PREFIX@' ]; then 654 PREFIX=/usr/local
629 PKGDATADIR=/usr/local/share
630 else
631 PKGDATADIR=${PREFIX}/share
632 fi
633fi 655fi
634 656
635# gnome packagedatadir 657# gnome prefix
636if [ ! -d "${GPKGDATADIR}" -o -z "${GPKGDATADIR}" ]; then 658for GNOME_PREFIX in "${GNOME_PREFIX}" /usr /opt /usr/local "${PREFIX}"; do
637 GPKGDATADIR=${PKGDATADIR} 659 if [ -n "${GNOME_PREFIX}" -a -d "$GNOME_PREFIX/share/gnome" ]; then
638fi 660 break;
661 fi
662done
663# Will remain $PREFIX if all else fails
639 664
640# kde packagedatadir 665# kde prefix
641if [ ! -d "${KPKGDATADIR}" -o -z "${KPKGDATADIR}" ]; then 666for KDE_PREFIX in "${KDE_PREFIX}" /usr /opt /usr/local "${PREFIX}"; do
642 KPKGDATADIR=${PKGDATADIR} 667 if [ -n "${KDE_PREFIX}" -a -d "$KDE_PREFIX/share/applnk" ]; then
643fi 668 break;
669 fi
670done
644 671
645# directory for the backgrounds 672# directory for the backgrounds
646if [ -z "$BACKGROUND_DIRS" ]; then 673if [ -z "$BACKGROUND_DIRS" ]; then
647 BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:${PKGDATADIR}/fluxbox/backgrounds/" 674 BACKGROUND_DIRS="${HOME}/.fluxbox/backgrounds/:${PREFIX}/share/fluxbox/backgrounds/"
648fi 675fi
649 676
650# find the default terminal 677# find the default terminal
@@ -833,39 +860,22 @@ append_submenu "${GAMESMENU}"
833 find_it et append "[exec] (Enemy Territory) {et}" 860 find_it et append "[exec] (Enemy Territory) {et}"
834append_menu_end 861append_menu_end
835 862
863# We'll only use this once
864ETCAPPLNK=/etc/X11/applnk
836# gnome menu 865# gnome menu
837if [ -d ${GPKGDATADIR}/gnome/apps -a "${GNOMEMENU}" ]; then 866if [ -d "${GNOME_PREFIX}/share/gnome/apps" -a "${GNOMEMENU}" ]; then
838 append_submenu "${GNOMEMENUTEXT}" 867 append_submenu "${GNOMEMENUTEXT}"
839 for a in `ls ${GPKGDATADIR}/gnome/apps/` ; do 868 recurse_dir_menu "${GNOME_PREFIX}/share/gnome/apps" ${ETCAPPLNK}
840 if [ -d ${GPKGDATADIR}/gnome/apps/"${a}" ]; then
841 append_submenu "${a}"
842 menu_entry_dir "${GPKGDATADIR}/gnome/apps/${a}"
843 menu_entry_dircheck "/etc/X11/applnk/${a}"
844 append_menu_end
845 fi
846 done
847 append_menu_end 869 append_menu_end
870 ETCAPPLNK=
848fi 871fi
849 872
850# kde submenu 873# kde submenu
851if [ -d ${KPKGDATADIR}/applnk/ -a "${KDEMENU}" ]; then 874if [ -d "${KDE_PREFIX}/share/applnk/" -a "${KDEMENU}" ]; then
852 append_submenu "${KDEMENUTEXT}" 875 append_submenu "${KDEMENUTEXT}"
853 for a in `ls ${KPKGDATADIR}/applnk/` ; do 876 recurse_dir_menu "${KDE_PREFIX}/share/applnk" ${ETCAPPLNK}
854 if [ -d ${KPKGDATADIR}/applnk/"${a}" ]; then
855 append_submenu "${a}"
856 for x in ${KPKGDATADIR}/applnk/"${a}"/*; do
857 if [ -d ${KPKGDATADIR}/applnk/"${a}"/"${x}" ]; then
858 append_submenu "${x}"
859 menu_entry_dir ${KPKGDATADIR}/applnk/"${a}"/"${x}"
860 append_menu_end
861 fi
862 done
863 menu_entry_dir ${KPKGDATADIR}/applnk/"${a}"
864 append_menu_end
865 fi
866 done
867 menu_entry_dir ${KPKGDATADIR}/applnk/
868 append_menu_end 877 append_menu_end
878 ETCAPPLNK=
869fi 879fi
870 880
871#User menu 881#User menu
@@ -877,7 +887,7 @@ append_submenu "${FBSETTINGSMENU}"
877 append "[config] (${CONFIGUREMENU})" 887 append "[config] (${CONFIGUREMENU})"
878 888
879 append_menu "[submenu] (${SYSTEMSTYLES}) {${STYLEMENUTITLE}}" 889 append_menu "[submenu] (${SYSTEMSTYLES}) {${STYLEMENUTITLE}}"
880 append "[stylesdir] (${PKGDATADIR}/fluxbox/styles)" 890 append "[stylesdir] (${PREFIX}/share/fluxbox/styles)"
881 append_menu_end 891 append_menu_end
882 892
883 append_menu "[submenu] (${USERSTYLES}) {${STYLEMENUTITLE}}" 893 append_menu "[submenu] (${USERSTYLES}) {${STYLEMENUTITLE}}"