diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-24 09:30:49 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-24 09:30:49 (GMT) |
commit | 088f4189273f668e5ca5ed5d7c94eaca47081319 (patch) | |
tree | e0728b996bc0a21b77cb68198fb3c18c590137fc /util | |
parent | d6e009af98917ab3887e1c4e2d34fcf5b3373c07 (diff) | |
download | fluxbox_pavel-088f4189273f668e5ca5ed5d7c94eaca47081319.zip fluxbox_pavel-088f4189273f668e5ca5ed5d7c94eaca47081319.tar.bz2 |
replaced `which' with the bourne shell built-in `hash' and fixed some --program-prefix/suffix problems
Diffstat (limited to 'util')
-rwxr-xr-x | util/fluxbox-generate_menu.in | 69 |
1 files changed, 21 insertions, 48 deletions
diff --git a/util/fluxbox-generate_menu.in b/util/fluxbox-generate_menu.in index b4996c0..92839ba 100755 --- a/util/fluxbox-generate_menu.in +++ b/util/fluxbox-generate_menu.in | |||
@@ -51,7 +51,7 @@ WHOAMI=`whoami` | |||
51 | [ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin | 51 | [ "$WHOAMI" = root ] && PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin |
52 | 52 | ||
53 | # Check for Imlib2-support | 53 | # Check for Imlib2-support |
54 | if fluxbox -info 2> /dev/null | grep -q "^IMLIB"; then | 54 | if @pkgprefix@fluxbox@pkgsuffix@ -info 2> /dev/null | grep -q "^IMLIB"; then |
55 | PNG_ICONS="yes" | 55 | PNG_ICONS="yes" |
56 | else | 56 | else |
57 | # better assume to assume "no" | 57 | # better assume to assume "no" |
@@ -110,6 +110,7 @@ Files: | |||
110 | EOF | 110 | EOF |
111 | } | 111 | } |
112 | 112 | ||
113 | #' | ||
113 | display_authors() { | 114 | display_authors() { |
114 | cat << EOF | 115 | cat << EOF |
115 | 116 | ||
@@ -125,42 +126,13 @@ display_authors() { | |||
125 | EOF | 126 | EOF |
126 | } | 127 | } |
127 | 128 | ||
128 | # some which's have a reliable return code, some don't | 129 | find_it() { |
129 | # Lets figure out which which we have. | 130 | [ -n "$1" ] && hash $1 2> /dev/null && shift && "$@" |
130 | if which this_program_does_not_exist-no_really-aA1zZ9 2> /dev/null 1> /dev/null; then | 131 | } |
131 | # can't rely on return value | ||
132 | find_it() { | ||
133 | file=`which $1 2> /dev/null` | ||
134 | if [ -x "$file" ]; then | ||
135 | if [ $# -gt 1 ]; then | ||
136 | shift | ||
137 | "$@" | ||
138 | fi | ||
139 | return 0 | ||
140 | else | ||
141 | return 1 | ||
142 | fi | ||
143 | } | ||
144 | |||
145 | find_it_options() { | ||
146 | file=`which $1 2> /dev/null` | ||
147 | if [ -x "$file" ]; then | ||
148 | return 0 | ||
149 | else | ||
150 | return 1 | ||
151 | fi | ||
152 | } | ||
153 | |||
154 | else | ||
155 | # can rely on return value | ||
156 | find_it() { | ||
157 | which $1 > /dev/null 2>&1 && shift && "$@" | ||
158 | } | ||
159 | 132 | ||
160 | find_it_options() { | 133 | find_it_options() { |
161 | which $1 > /dev/null 2>&1 | 134 | [ -n "$1" ] && hash $1 2> /dev/null |
162 | } | 135 | } |
163 | fi | ||
164 | 136 | ||
165 | #echo "replaceWithinString: $1, $2, $3" >&2 | 137 | #echo "replaceWithinString: $1, $2, $3" >&2 |
166 | #echo ${1//$2/$3} # causes error in BSD even though not used | 138 | #echo ${1//$2/$3} # causes error in BSD even though not used |
@@ -212,7 +184,7 @@ convertIcon(){ | |||
212 | if [ -f "${entry_icon}" ]; then | 184 | if [ -f "${entry_icon}" ]; then |
213 | : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 | 185 | : echo "File exists. To overwrite, type: convert \"$1\" \"$entry_icon\"" >&2 |
214 | else | 186 | else |
215 | if which convert &> /dev/null; then | 187 | if hash convert 2> /dev/null; then |
216 | convert "$1" "$entry_icon" | 188 | convert "$1" "$entry_icon" |
217 | # echo convert "$1" , "$entry_icon" >> $ICONMAPPING | 189 | # echo convert "$1" , "$entry_icon" >> $ICONMAPPING |
218 | else | 190 | else |
@@ -1243,7 +1215,7 @@ if [ ! "${INSTALL}" = Yes ]; then | |||
1243 | # Name of the outputfile | 1215 | # Name of the outputfile |
1244 | # MENUFILENAME=${USERFLUXDIR}/menu | 1216 | # MENUFILENAME=${USERFLUXDIR}/menu |
1245 | 1217 | ||
1246 | # MENUTITLE=\`fluxbox -version|cut -d " " -f-2\` | 1218 | # MENUTITLE=\`@pkgprefix@fluxbox@pkgsuffix@ -version|cut -d " " -f-2\` |
1247 | 1219 | ||
1248 | # standard url for console-browsers | 1220 | # standard url for console-browsers |
1249 | # HOMEPAGE=fluxbox.org | 1221 | # HOMEPAGE=fluxbox.org |
@@ -1252,7 +1224,7 @@ if [ ! "${INSTALL}" = Yes ]; then | |||
1252 | # USERMENU=~/.@pkgprefix@fluxbox@pkgsuffix@/usermenu | 1224 | # USERMENU=~/.@pkgprefix@fluxbox@pkgsuffix@/usermenu |
1253 | 1225 | ||
1254 | # Put the launcher you would like to use here | 1226 | # Put the launcher you would like to use here |
1255 | # LAUNCHER=fbrun | 1227 | # LAUNCHER=@pkgprefix@fbrun@pkgsuffix@ |
1256 | # LAUNCHER=fbgm | 1228 | # LAUNCHER=fbgm |
1257 | 1229 | ||
1258 | # Options for fbrun | 1230 | # Options for fbrun |
@@ -1436,7 +1408,8 @@ fi | |||
1436 | # prefix | 1408 | # prefix |
1437 | PREFIX="${PREFIX:=@PREFIX@}" | 1409 | PREFIX="${PREFIX:=@PREFIX@}" |
1438 | if [ -z "${PREFIX}" -o ! -d "${PREFIX}" ]; then | 1410 | if [ -z "${PREFIX}" -o ! -d "${PREFIX}" ]; then |
1439 | PREFIX=`which fluxbox | sed 's,/bin/fluxbox$,,'` | 1411 | hash @pkgprefix@fluxbox@pkgsuffix@ |
1412 | PREFIX=`hash -t @pkgprefix@fluxbox@pkgsuffix@ | sed 's,/bin/@pkgprefix@fluxbox@pkgsuffix@$,,'` | ||
1440 | fi | 1413 | fi |
1441 | 1414 | ||
1442 | 1415 | ||
@@ -1510,7 +1483,7 @@ else | |||
1510 | [ -n "$MY_TERM" ] && echo "Warning: you chose an invalid term." >&2 | 1483 | [ -n "$MY_TERM" ] && echo "Warning: you chose an invalid term." >&2 |
1511 | #The precise order is up for debate. | 1484 | #The precise order is up for debate. |
1512 | for term in Eterm urxvt urxvtc aterm mrxvt rxvt wterm konsole gnome-terminal xterm; do | 1485 | for term in Eterm urxvt urxvtc aterm mrxvt rxvt wterm konsole gnome-terminal xterm; do |
1513 | if find_it $term; then | 1486 | if find_it_options $term; then |
1514 | DEFAULT_TERM=$term | 1487 | DEFAULT_TERM=$term |
1515 | break | 1488 | break |
1516 | fi | 1489 | fi |
@@ -1538,7 +1511,7 @@ else | |||
1538 | [ -n "$MY_BROWSER" ] && echo "Warning: you chose an invalid browser." >&2 | 1511 | [ -n "$MY_BROWSER" ] && echo "Warning: you chose an invalid browser." >&2 |
1539 | #The precise order is up for debate. | 1512 | #The precise order is up for debate. |
1540 | for browser in firefox mozilla-firefox mozilla-firebird MozillaFirebird opera skipstone mozilla seamonkey galeon konqueror dillo netscape w3m amaya links lynx; do | 1513 | for browser in firefox mozilla-firefox mozilla-firebird MozillaFirebird opera skipstone mozilla seamonkey galeon konqueror dillo netscape w3m amaya links lynx; do |
1541 | if find_it $browser; then | 1514 | if find_it_options $browser; then |
1542 | DEFAULT_BROWSER=$browser | 1515 | DEFAULT_BROWSER=$browser |
1543 | break | 1516 | break |
1544 | fi | 1517 | fi |
@@ -1548,7 +1521,7 @@ DEFAULT_BROWSERNAME=`echo $DEFAULT_BROWSER|awk '{print $1}'` | |||
1548 | DEFAULT_BROWSERNAME=`basename $DEFAULT_BROWSERNAME` | 1521 | DEFAULT_BROWSERNAME=`basename $DEFAULT_BROWSERNAME` |
1549 | 1522 | ||
1550 | if [ -z "$LAUNCHER" ]; then | 1523 | if [ -z "$LAUNCHER" ]; then |
1551 | LAUNCHER=fbrun | 1524 | LAUNCHER=@pkgprefix@fbrun@pkgsuffix@ |
1552 | fi | 1525 | fi |
1553 | 1526 | ||
1554 | # Start of menu | 1527 | # Start of menu |
@@ -1830,7 +1803,7 @@ append_submenu "${FBSETTINGSMENU}" | |||
1830 | # Backgroundmenu | 1803 | # Backgroundmenu |
1831 | addbackground() { | 1804 | addbackground() { |
1832 | picturename=`basename "$1"` | 1805 | picturename=`basename "$1"` |
1833 | append "[exec] (${picturename%.???}) {fbsetbg -a \"$1\" }" | 1806 | append "[exec] (${picturename%.???}) {@pkgprefix@fbsetbg@pkgsuffix@ -a \"$1\" }" |
1834 | } | 1807 | } |
1835 | 1808 | ||
1836 | if [ "$BACKGROUNDMENUITEM" = yes ]; then | 1809 | if [ "$BACKGROUNDMENUITEM" = yes ]; then |
@@ -1838,7 +1811,7 @@ append_submenu "${FBSETTINGSMENU}" | |||
1838 | NUMBER_OF_BACKGROUNDS=`find $BACKGROUND_DIRS -follow -type f 2> /dev/null|wc -l` | 1811 | NUMBER_OF_BACKGROUNDS=`find $BACKGROUND_DIRS -follow -type f 2> /dev/null|wc -l` |
1839 | if [ "$NUMBER_OF_BACKGROUNDS" -gt 0 ]; then | 1812 | if [ "$NUMBER_OF_BACKGROUNDS" -gt 0 ]; then |
1840 | append_menu "[submenu] (${BACKGROUNDMENU}) {${BACKGROUNDMENUTITLE}}" | 1813 | append_menu "[submenu] (${BACKGROUNDMENU}) {${BACKGROUNDMENUTITLE}}" |
1841 | append "[exec] (${RANDOMBACKGROUND}) {fbsetbg -r ${USERFLUXDIR}/backgrounds}" | 1814 | append "[exec] (${RANDOMBACKGROUND}) {@pkgprefix@fbsetbg@pkgsuffix@ -r ${USERFLUXDIR}/backgrounds}" |
1842 | if [ "$NUMBER_OF_BACKGROUNDS" -gt 30 ]; then | 1815 | if [ "$NUMBER_OF_BACKGROUNDS" -gt 30 ]; then |
1843 | menucounter=1 ; counter=1 | 1816 | menucounter=1 ; counter=1 |
1844 | append_menu "[submenu] (${BACKGROUNDMENU} $menucounter) {${BACKGROUNDMENUTITLE}}" | 1817 | append_menu "[submenu] (${BACKGROUNDMENU} $menucounter) {${BACKGROUNDMENUTITLE}}" |
@@ -1880,7 +1853,7 @@ append_submenu "${FBSETTINGSMENU}" | |||
1880 | find_it ${LAUNCHER} append "[exec] (${RUNCOMMAND}) {${LAUNCHER} $FBRUNOPTIONS}" | 1853 | find_it ${LAUNCHER} append "[exec] (${RUNCOMMAND}) {${LAUNCHER} $FBRUNOPTIONS}" |
1881 | find_it switch append "[exec] (gtk-theme-switch) {switch}" | 1854 | find_it switch append "[exec] (gtk-theme-switch) {switch}" |
1882 | find_it switch2 append "[exec] (gtk2-theme-switch) {switch2}" | 1855 | find_it switch2 append "[exec] (gtk2-theme-switch) {switch2}" |
1883 | find_it $0 append "[exec] (${REGENERATEMENU}) {@pkgprefix@fluxbox-generate_menu@pkgsuffix@ ${BACKUPOPTIONS}}" | 1856 | find_it @pkgprefix@fluxbox-generate_menu@pkgsuffix@ append "[exec] (${REGENERATEMENU}) {@pkgprefix@fluxbox-generate_menu@pkgsuffix@ ${BACKUPOPTIONS}}" |
1884 | append_menu_end | 1857 | append_menu_end |
1885 | 1858 | ||
1886 | append_submenu "${WINDOWMANAGERS}" | 1859 | append_submenu "${WINDOWMANAGERS}" |
@@ -1900,7 +1873,7 @@ append_submenu "${FBSETTINGSMENU}" | |||
1900 | append "[commanddialog] (${FLUXBOXCOMMAND})" | 1873 | append "[commanddialog] (${FLUXBOXCOMMAND})" |
1901 | append "[reconfig] (${RELOADITEM})" | 1874 | append "[reconfig] (${RELOADITEM})" |
1902 | append "[restart] (${RESTARTITEM})" | 1875 | append "[restart] (${RESTARTITEM})" |
1903 | append "[exec] (${ABOUTITEM}) {(fluxbox -v; fluxbox -info | sed 1d) | xmessage -file - -center}" | 1876 | append "[exec] (${ABOUTITEM}) {(@pkgprefix@fluxbox@pkgsuffix@ -v; @pkgprefix@fluxbox@pkgsuffix@ -info | sed 1d) | xmessage -file - -center}" |
1904 | append "[separator]" | 1877 | append "[separator]" |
1905 | append "[exit] (${EXITITEM})" | 1878 | append "[exit] (${EXITITEM})" |
1906 | 1879 | ||
@@ -1933,6 +1906,6 @@ if [ -z "$INSTALL" ]; then | |||
1933 | fi | 1906 | fi |
1934 | fi | 1907 | fi |
1935 | echo "Menu successfully generated: $MENUFILENAME" | 1908 | echo "Menu successfully generated: $MENUFILENAME" |
1936 | #echo " Make sure \"session.menuFile: $MENUFILENAME\" is in $HOME/.fluxbox/init." | 1909 | #echo " Make sure \"session.menuFile: $MENUFILENAME\" is in $HOME/.@pkgprefix@fluxbox@pkgsuffix@/init." |
1937 | echo 'Use @pkgprefix@fluxbox-generate_menu@pkgsuffix@ -h to read about all the latest features.' | 1910 | echo 'Use @pkgprefix@fluxbox-generate_menu@pkgsuffix@ -h to read about all the latest features.' |
1938 | fi | 1911 | fi |