~ubuntu-branches/debian/sid/menu/sid

« back to all changes in this revision

Viewing changes to doc/menu.html/ch7.html

  • Committer: Bazaar Package Importer
  • Author(s): Bill Allombert
  • Date: 2005-05-24 10:34:47 UTC
  • mfrom: (1.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050524103447-9zu50so5d0nte3o9
Tags: 2.1.24
* The "head or tail" release 
* Fix .menus typo in menufile.5. Closes: #306564. Thanks Sean Finney.
* Add Vietnamese menu messages and menu sections translations.
  Thanks Clytie Siddall. Closes: #307450, #308953.
* Update Esperanto menu sections translation. Thanks MJ Ray.
* Add Esperanto menu messages translation. Thanks MJ Ray.
* Unfuzzy Norwegian Bokmål menu messages translation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
 
2
 
 
3
<html>
 
4
 
 
5
<head>
 
6
 
 
7
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
 
8
 
 
9
<title>Debian Menu System - The internals of the menu package</title>
 
10
 
 
11
</head>
 
12
 
 
13
<body>
 
14
 
 
15
<a name="ch7"></a>
 
16
<hr>
 
17
 
 
18
[ <a href="ch6.html">previous</a> ]
 
19
[ <a href="index.html#contents">Contents</a> ]
 
20
[ <a href="ch1.html">1</a> ]
 
21
[ <a href="ch2.html">2</a> ]
 
22
[ <a href="ch3.html">3</a> ]
 
23
[ <a href="ch4.html">4</a> ]
 
24
[ <a href="ch5.html">5</a> ]
 
25
[ <a href="ch6.html">6</a> ]
 
26
[ 7 ]
 
27
[ <a href="ch8.html">8</a> ]
 
28
[ <a href="ch8.html">next</a> ]
 
29
 
 
30
<hr>
 
31
 
 
32
<h1>
 
33
Debian Menu System
 
34
<br>Chapter 7 - The internals of the menu package
 
35
</h1>
 
36
 
 
37
<hr>
 
38
 
 
39
<a name="s7.1"></a>
 
40
<h2>7.1 The update-menus program</h2>
 
41
 
 
42
<p>
 
43
On startup, update-menus checks the file <samp>/var/run/update-menus.pid</samp>
 
44
and the pid in it.  If there's an <code>update-menus</code> process with that
 
45
pid it kills it.  If <samp>/var/lib/dpkg/lock</samp> exists, it forks to
 
46
background and returns control to dpkg.  The background process checks the
 
47
<samp>/var/lib/dpkg/lock</samp> file approx.  every second until the file's
 
48
gone.
 
49
 
 
50
<p>
 
51
After that, <code>update-menus</code> reads the menu-entry-files in the
 
52
following directories:<samp>/etc/menu /usr/lib/menu
 
53
/usr/share/menu/default</samp> (if a user runs <code>update-menus</code>, it
 
54
will add ~/.menu to the front of that list).  For every menu entry line in each
 
55
file it checks if the corresponding package is installed (works on file bases
 
56
for old syntax menu entry files).  The menu entries of all
 
57
&quot;installed&quot; packages are added together in one big buffer that is
 
58
kept in memory (exception: executable menu entry files are executed, and stdout
 
59
is placed in the buffer).
 
60
 
 
61
<p>
 
62
Once it's read all menu entry files, <code>update-menus</code> starts all
 
63
executable scripts in /etc/menu-methods/, hands the scripts the previously
 
64
created buffer via stdin.  (If <code>update-menus</code> is ran by a user, it
 
65
will first try to run the scripts in ~/.menu-methods, and only if that
 
66
directory doesn't exist, it will run the scripts in /etc/menu-methods).
 
67
 
 
68
<p>
 
69
Note that as an aid to debugging, one can use
 
70
 
 
71
<pre>
 
72
     update-menus --stdout &gt; /tmp/menu-stdin
 
73
</pre>
 
74
 
 
75
<p>
 
76
and then view the file /tmp/menu-stdin to see exactly what
 
77
<samp>update-menus</samp> handed the menu-methods on their stdin.
 
78
 
 
79
<p>
 
80
This may also be useful for people writing /etc/menu-method/* scripts: Running
 
81
<code>update-menus</code> every time you changed something in the script may be
 
82
quite time-consuming.  So, it's much easier to run <code>update-menus
 
83
--stdout</code> once, and then run
 
84
 
 
85
<pre>
 
86
       /etc/menu-methods/mymethod &lt; /tmp/menu-stdin
 
87
</pre>
 
88
 
 
89
<p>
 
90
(and, if that also takes too long, just try editing /tmp/menu-stdin, and
 
91
removing 90% or so of all entries)
 
92
 
 
93
<hr>
 
94
 
 
95
<a name="s7.2"></a>
 
96
<h2>7.2 The install-menu program</h2>
 
97
 
 
98
<p>
 
99
The files <samp>/etc/menu-methods/$wm</samp> are executable config files that
 
100
start with the line
 
101
 
 
102
<pre>
 
103
       #!/usr/sbin/install-menu
 
104
</pre>
 
105
 
 
106
<p>
 
107
and thus start that program, handing it the configuration file for the specific
 
108
window manager in the first command line argument.  This configuration consists
 
109
of:
 
110
<ol type="1" start="1" >
 
111
<li>
 
112
the compatibility mode (&quot;menu-1&quot; or &quot;menu-2&quot;).
 
113
</li>
 
114
</ol>
 
115
<ol type="1" start="2" >
 
116
<li>
 
117
where the various files should be stored/read.
 
118
</li>
 
119
</ol>
 
120
<ol type="1" start="3" >
 
121
<li>
 
122
what &quot;needs&quot; are supported, and what wrapper files should be used for
 
123
each &quot;type&quot;.
 
124
</li>
 
125
</ol>
 
126
 
 
127
<p>
 
128
See <samp>/usr/share/doc/menu/examples/</samp> of the menu package for more
 
129
comments.
 
130
 
 
131
<p>
 
132
Options to <code>install-menu</code>:
 
133
 
 
134
<pre>
 
135
       -v              be verbose
 
136
       -d              Produce loads of debugging output
 
137
</pre>
 
138
 
 
139
<p>
 
140
Some window managers don't support an `include' like statement in their
 
141
<samp>system.*rc</samp> files (like <code>m4</code> or <code>cpp</code>
 
142
preprocessing), they cannot read the <samp>menudefs.hook</samp> file generated
 
143
by install-menu from their <samp>system.*rc</samp> config file.  To still be
 
144
able to use them, <code>install-menu</code> will copy the file
 
145
<samp>$path/$examplercfile</samp> to <samp>$path/$rcfile</samp> (with
 
146
<samp>$examplercfile</samp> and <samp>$rcfile</samp> defined in the
 
147
<code>install-menu</code> config file, and <samp>$path</samp> either the
 
148
<samp>$rootprefix</samp> or <samp>${HOME}/$userprefix</samp>, depending on
 
149
whether root or user executed the file.), and replace all occurrences of
 
150
``install-menu-defs'' with the <samp>$genmenu</samp> file it just generated.
 
151
 
 
152
<p>
 
153
As an example, consider the following:
 
154
<samp>examplercfile=system.foo-wm-example</samp>,
 
155
<samp>rcfile=system.foo-wm</samp>, <samp>genmenu=menudefs.hook</samp> and
 
156
<samp>rootprefix=/etc/X11/foo-wm</samp>.  Now, if <code>install-menu</code>
 
157
gets run, it will first generate the file
 
158
<samp>/etc/X11/foo-wm/menudefs.hook</samp>.  Next, it will line-by-line read
 
159
the file <samp>/etc/X11/foo-wm/system.foo-wm-example</samp> and copy it's
 
160
contents to <samp>/etc/X11/foo-wm/system.foo-wm</samp>, replacing every
 
161
occurrence of the string <samp>install-menu-defs</samp> by the contents of the
 
162
file <samp>/etc/X11/foo-wm/menudefs.hook</samp>.
 
163
 
 
164
<p>
 
165
To activate the file copying in this way, simply define the
 
166
<samp>$examplercfile</samp> and <samp>$rcfile</samp> variables in the
 
167
<code>install-menu</code> configuration file (for example, see
 
168
<samp>/etc/menu-methods/fvwm</samp>), and make sure there is a
 
169
<samp>$path/$examplercfile</samp> (<samp>$path</samp> being either
 
170
<samp>$rootprefix</samp>, or <samp>$userprefix</samp>.)
 
171
 
 
172
<p>
 
173
If you are wringing a menu method, you can use the following to debug it
 
174
somewhat easier:
 
175
<ol type="1" start="1" >
 
176
<li>
 
177
use <samp>update-menus --stdout &gt; /tmp/menu-stdin</samp> to create a list of
 
178
menu entries in <samp>/tmp/menu-stdin</samp> and then
 
179
</li>
 
180
</ol>
 
181
<ol type="1" start="2" >
 
182
<li>
 
183
you can run just your menu-method with (if it's called wm):
 
184
 
 
185
<pre>
 
186
       ./wm -v &lt; /tmp/menu-stdin
 
187
</pre>
 
188
 
 
189
<p>
 
190
(Use <samp>-v</samp> for verbose, <samp>-d</samp> for debugging, and you'll get
 
191
loads of output!)
 
192
</li>
 
193
</ol>
 
194
 
 
195
<hr>
 
196
 
 
197
<a name="s7.3"></a>
 
198
<h2>7.3 The install-menu config script definitions</h2>
 
199
 
 
200
<p>
 
201
The menu-methods in <samp>/etc/menu-methods/*</samp> are basically made up of a
 
202
lot of ``tag=string'' definitions, explaining <code>install-menu</code> how to
 
203
generate a <samp>system.$wmrc</samp> script.  This way you can tune the look of
 
204
generated <samp>system.$wmrc</samp> to your needs.
 
205
 
 
206
<p>
 
207
In the following, something like
 
208
 
 
209
<pre>
 
210
       treewalk=&quot;c(m)&quot;
 
211
</pre>
 
212
 
 
213
<p>
 
214
means that the treewalk variable by default has the value &quot;c(m)&quot;.
 
215
 
 
216
<p>
 
217
For examples of what these scripts can look like, see
 
218
<samp>/usr/share/doc/menu/examples/*</samp>.
 
219
<dl>
 
220
<dt><samp>compat=&quot;menu-1&quot;</samp></dt>
 
221
<dd>
 
222
Two mode are defined:
 
223
<dl>
 
224
<dt><samp>&quot;menu-1&quot;</samp></dt>
 
225
<dd>
 
226
menu directives are terminated by an end-of-line character.
 
227
</dd>
 
228
</dl>
 
229
<dl>
 
230
<dt><samp>&quot;menu-2&quot;</samp></dt>
 
231
<dd>
 
232
menu directives are terminated by semi-comma character.
 
233
</dd>
 
234
</dl>
 
235
 
 
236
<p>
 
237
This must be just after the <samp>!include &quot;menu.h&quot;</samp> directive
 
238
so that <code>menu.h</code> can use its own compat mode.
 
239
</dd>
 
240
</dl>
 
241
<dl>
 
242
<dt><samp>outputencoding=&quot;UTF-8&quot;</samp></dt>
 
243
<dd>
 
244
Set the encoding used for output files.  Use <samp>iconv --list</samp> to get
 
245
the list of supported encoding.  Useful values include &quot;UTF-8&quot; and
 
246
&quot;ISO-8859-1&quot;.  The special value &quot;LOCALE&quot; means that the
 
247
current locale encoding will be used.  If set to an empty string, no
 
248
translations are performed.  This is the default.
 
249
</dd>
 
250
</dl>
 
251
<dl>
 
252
<dt><samp>outputlanguage=&quot;&quot;</samp></dt>
 
253
<dd>
 
254
If set to &quot;C&quot; automatic translations will be disabled.  Note that you
 
255
can still use translate() to perform explicit translation.
 
256
</dd>
 
257
</dl>
 
258
<dl>
 
259
<dt><samp>supported</samp></dt>
 
260
<dt><samp>endsupported</samp></dt>
 
261
<dd>
 
262
Between the <samp>supported</samp> and <samp>endsupported</samp> keywords you
 
263
define what &quot;needs&quot; are supported by this window manager.  So, the
 
264
following is an example for a wm that supports both needs=x11 and needs=text:
 
265
 
 
266
<pre>
 
267
       function q($s) = &quot;\&quot;&quot; esc($s,&quot;\\\&quot;&quot;) &quot;\&quot;&quot;
 
268
       supported
 
269
         x11 =&quot; ShowEntry(&quot; q(title()) &quot;, &quot; q($command) &quot;)&quot;
 
270
         text=&quot; ShowEntry(&quot; q(title()) &quot;, &quot; q(term())   &quot;)&quot;
 
271
       endsupported
 
272
</pre>
 
273
 
 
274
<p>
 
275
For the variable substitution (and functions, not shown above), see the next
 
276
paragraph.  In the above example, you'll notice that for the menu entries that
 
277
&quot;need=text&quot;, the term() function is used.  This is an user-supplied
 
278
function that will run $command in a X terminal emulator.  Also, as x11 is
 
279
higher up in the supported list above than text, a package that supplies both a
 
280
&quot;needs=x11&quot; and a &quot;needs=text&quot; entry will have the
 
281
needs=x11 entry installed, in favour of the needs=text entry.  You can continue
 
282
lines on the next line with a \, but do make sure you don't add any spaces
 
283
after the \.
 
284
</dd>
 
285
</dl>
 
286
<dl>
 
287
<dt><samp>startmenu=&quot;&quot;</samp></dt>
 
288
<dt><samp>endmenu=&quot;&quot;</samp></dt>
 
289
<dt><samp>submenutitle=&quot;&quot;</samp></dt>
 
290
<dd>
 
291
These define what to print for the beginning/end of a menu, and how to the
 
292
print a menu entry that pops up another menu entry.  They are substituted the
 
293
same way as the &quot;supported&quot; stuff is.  (see next paragraph).
 
294
</dd>
 
295
</dl>
 
296
<dl>
 
297
<dt><samp>treewalk=&quot;c(m)&quot;</samp></dt>
 
298
<dd>
 
299
This string defines in what order to dump the <samp>$startmenu</samp>,
 
300
<samp>$endmenu</samp>, and <samp>$submenutitle</samp> (and its children).  Each
 
301
char in the string refers to:
 
302
 
 
303
<pre>
 
304
         c  : dump children of menu.
 
305
         m  : dump this menu's $submenutitles
 
306
         (  : dump $startmenu
 
307
         )  : dump $endmenu
 
308
         M  : dump all $submenutitles of this menu and this menu's children.
 
309
</pre>
 
310
 
 
311
<p>
 
312
The default is &quot;c(m)&quot;.  For olvwm, one needs: &quot;(M)&quot;
 
313
</dd>
 
314
</dl>
 
315
<dl>
 
316
<dt><samp>genmenu=&quot;&quot;</samp></dt>
 
317
<dd>
 
318
The menu file to generate (usually something like
 
319
<samp>system.&quot;$wm&quot;rc</samp>).  The file itself may depend on the
 
320
level or title that is currently being worked on, like
 
321
 
 
322
<pre>
 
323
         genmenu=&quot;/subdir/&quot; replacewith($section,&quot; &quot;,&quot;_&quot;) &quot;/rc.menu&quot;
 
324
</pre>
 
325
 
 
326
<p>
 
327
(Substitution works just like in the supported stuff, see above).  Note that
 
328
the files made this way are truncated upon opening, so if you have a genmenu
 
329
like the example above, then your <samp>endmenu=</samp> will override the
 
330
startmenu stuff (but you probably only need one of the two anyway).
 
331
</dd>
 
332
</dl>
 
333
<dl>
 
334
<dt><samp>rootsection=&quot;/Debian&quot;</samp></dt>
 
335
<dd>
 
336
the prefix, every <samp>$section</samp> variable gets.
 
337
</dd>
 
338
</dl>
 
339
<dl>
 
340
<dt><samp>prerun=&quot;&quot;</samp></dt>
 
341
<dt><samp>postrun=&quot;&quot;</samp></dt>
 
342
<dd>
 
343
The commands to run before resp.  after the actual generation of the
 
344
<samp>menudefs.hook</samp> (genmenu) file.  Commands will be executed by
 
345
<code>sh</code>.  Example:
 
346
 
 
347
<pre>
 
348
       prerun=&quot;rm -rf &quot; prefix() &quot;/*&quot;
 
349
       postrun=&quot;killall -USR1 fvwm2&quot;
 
350
</pre>
 
351
 
 
352
<p>
 
353
(Substitution works just like the supported stuff, see below).
 
354
</dd>
 
355
</dl>
 
356
<dl>
 
357
<dt><samp>preruntest=&quot;&quot;</samp></dt>
 
358
<dd>
 
359
Just like prerun, but if the return value of the command is non-zero, menu will
 
360
quit.
 
361
</dd>
 
362
</dl>
 
363
<dl>
 
364
<dt><samp>also_run=&quot;&quot;</samp></dt>
 
365
<dd>
 
366
If non-zero, install-menus will, after generating the output files, also load
 
367
the file also_run, and use the new assignments to treewalk, genmenu, etc to
 
368
generate more output.  This second time, variables like <samp>prerun</samp> and
 
369
all of the hint stuff are ignored.
 
370
 
 
371
<p>
 
372
Note: NOT just like <samp>prerun</samp> etc: <samp>prerun</samp> etc start a
 
373
command with /bin/sh, <samp>also_run</samp> doesn't exec any other command,
 
374
just tells install-menu to also load another binary, and generate the output.
 
375
</dd>
 
376
</dl>
 
377
<dl>
 
378
<dt><samp>onlyrunasroot=false</samp></dt>
 
379
<dt><samp>onlyrunasuser=false</samp></dt>
 
380
<dd>
 
381
If <samp>onlyrunasroot</samp> is set to true, menu will quit silently when run
 
382
as user.  Similarly for <samp>onlyrunasuser</samp>.
 
383
<var><samp>onlyrunasroot</samp> is deprecated since it is simpler to just not
 
384
define <samp>userprefix</samp>.</var> On the other hand,
 
385
<samp>onlyrunasuser</samp> might be needed if you use <samp>rcfile</samp> since
 
386
<samp>rootprefix</samp> is used as a fallback location for the template.
 
387
</dd>
 
388
</dl>
 
389
<dl>
 
390
<dt><samp>preoutput=&quot;#Automatically generated file. Do not edit (see /usr/share/doc/menu/html)\n\n&quot;</samp></dt>
 
391
<dt><samp>postoutput=&quot;&quot;</samp></dt>
 
392
<dd>
 
393
Text to put at the beginning resp.  end of the generated file ($genmenu).
 
394
</dd>
 
395
</dl>
 
396
<dl>
 
397
<dt><samp>command=&quot;&quot;</samp></dt>
 
398
<dd>
 
399
A command to run instead of <code>install-menus</code>.  This command used to
 
400
be needed to get around limitations due to compatibility stuff.  But that
 
401
compatibility with pre menu-1 stuff has been dropped, and isn't needed any
 
402
more.
 
403
 
 
404
<p>
 
405
Example:
 
406
 
 
407
<pre>
 
408
       command=&quot;cat &gt; /tmp/menu-stdin&quot;
 
409
</pre>
 
410
</dd>
 
411
</dl>
 
412
<dl>
 
413
<dt><samp>hotkeyexclude=&quot;&quot;</samp></dt>
 
414
<dd>
 
415
Keys not to use for hotkey generation.  You can use the same variables and
 
416
functions here as in for example the startmenu sections.
 
417
 
 
418
<p>
 
419
Example:
 
420
 
 
421
<pre>
 
422
       hotkeyexclude=&quot;q&quot; $section
 
423
</pre>
 
424
</dd>
 
425
</dl>
 
426
<dl>
 
427
<dt><samp>hotkeycase=&quot;insensitive&quot;</samp></dt>
 
428
<dd>
 
429
can be either &quot;insensitive&quot; or &quot;sensitive&quot;.  Determines
 
430
whether the hotkeys can be of mixed case (<samp>fvwm2</samp> reads the hotkeys
 
431
case-insensitive, <samp>pdmenu</samp> case-sensitive).  In case of the titles
 
432
&quot;Xa&quot; and &quot;xb&quot;, hotkey case-insensitive will generate
 
433
&quot;X&quot; and &quot;b&quot;, whereas case-sensitive would generate
 
434
&quot;X&quot; and &quot;x&quot;.
 
435
</dd>
 
436
</dl>
 
437
<dl>
 
438
<dt><samp>sort=$sort &quot;:&quot; $title</samp></dt>
 
439
<dd>
 
440
Entries within one menu will be alphabetically sorted by whatever sort returns.
 
441
So, if you do <samp>sort=ifelse($command, &quot;1&quot;,
 
442
&quot;0&quot;):$title</samp>, then all submenus will appear above the commands
 
443
in a submenu.  (A submenu always has <samp>$command=&quot;&quot;</samp>).  Or,
 
444
as Joey Hess writes:
 
445
 
 
446
<pre>
 
447
       You can add another field to the menu items, with whatever name you like,
 
448
       let's say it's called priority. Then add this line to
 
449
       /etc/menu-methods/*:
 
450
       
 
451
       sort=ifelse($priority, $priority, &quot;9&quot;)
 
452
       
 
453
       This has the result of sorting things so items with a low priority sort to the
 
454
       top, and items with no priority default to priority 9 and sort to the bottom.
 
455
       
 
456
       (Note that it compares the strings alphabetically, not numerically.)
 
457
</pre>
 
458
</dd>
 
459
</dl>
 
460
<dl>
 
461
<dt><samp>rcfile=&quot;&quot;</samp></dt>
 
462
<dd>
 
463
If the window manager doesn't support an &quot;include filename&quot; or
 
464
&quot;read(filename)&quot; statement in it's config file, you can rename the
 
465
wm's config file to <samp>system.&quot;$wm&quot;rc-menu</samp>, and insert a
 
466
&quot;install-menu-defs&quot; line (without the quotes, or whitespace around
 
467
it, and &quot;install-menu-defs&quot; must be the only thing on the line) in
 
468
the <samp>system.&quot;$wm&quot;rc-menu</samp> file.  This will then get
 
469
replaced by the <samp>$genmenu</samp> file that was just created (see also
 
470
<samp>$examplercfile</samp>).
 
471
</dd>
 
472
</dl>
 
473
<dl>
 
474
<dt><samp>examplercfile=&quot;&quot;</samp></dt>
 
475
<dd>
 
476
if needed (see <samp>rcfile</samp>), this is the
 
477
<samp>system.rc&quot;$wm&quot;-menu</samp> file.  In that case, make
 
478
<samp>rcfile=system.rc&quot;$wm&quot;</samp>.
 
479
</dd>
 
480
</dl>
 
481
<dl>
 
482
<dt><samp>rootprefix=&quot;&quot;</samp></dt>
 
483
<dd>
 
484
The prefix to use when running as root (applies to $genmenu, $rcfile,
 
485
$examplercfile and other old cache files).  If it is not defined, the
 
486
menu-method will be skipped when run as root.
 
487
</dd>
 
488
</dl>
 
489
<dl>
 
490
<dt><samp>userprefix=&quot;&quot;</samp></dt>
 
491
<dd>
 
492
As <samp>rootprefix</samp>, but when running as user.  userprefix is relative
 
493
to the user home directory, unless it start with 2 slashes, in which case it is
 
494
treated as an absolute path.  If it is not defined, the menu-method will be
 
495
skipped when run as a user.
 
496
</dd>
 
497
</dl>
 
498
<dl>
 
499
<dt><samp>hint_optimize=false</samp></dt>
 
500
<dd>
 
501
If set to true, menu will try to generate an `optimal' tree, using the
 
502
variables below.  If set to false, menu will keep the sections as they are
 
503
specified in the menu entry files (and ignore any hint stuff).
 
504
</dd>
 
505
</dl>
 
506
<dl>
 
507
<dt><samp>hint_nentry=6</samp></dt>
 
508
<dd>
 
509
Optimal number of entries in a submenu.  It's a float, so you can set it to 5.5
 
510
if you cannot decide between 5 and 6.  Also, values less than 3 probably don't
 
511
work very well at the moment.
 
512
</dd>
 
513
</dl>
 
514
<dl>
 
515
<dt><samp>hint_topnentry=5</samp></dt>
 
516
<dd>
 
517
Same as hint_nentry, but for the top level menu.  Often here are other entries,
 
518
added by the Window Manager itself (like Exit, Xterm, whatever) that menu
 
519
doesn't know about, so that you may want to instruct menu to put less entries
 
520
in the top level menu.
 
521
</dd>
 
522
</dl>
 
523
<dl>
 
524
<dt><samp>hint_mixedpenalty=15.0</samp></dt>
 
525
<dd>
 
526
Penalty for `mixed' menus.  Mixed menus are those with both submenus and direct
 
527
commands in them.
 
528
</dd>
 
529
</dl>
 
530
<dl>
 
531
<dt><samp>hint_minhintfreq=0.1</samp></dt>
 
532
<dd>
 
533
Minimal relative frequency for the hints before they are considered.  Internal
 
534
variable to speed up the tree generation.  If you find menu slow, increase this
 
535
value (to, say 0.2 or 0.3).
 
536
</dd>
 
537
</dl>
 
538
<dl>
 
539
<dt><samp>hint_mlpenalty=2000</samp></dt>
 
540
<dd>
 
541
`max local penalty', while evaluating the possible trees, menu gives
 
542
`penalties' for submenus that don't contain the desired number of submenus.
 
543
The penalty is sqrt(n_entry_opt-n_entry), and eventually will be calculated as
 
544
a sum of all nodes.  But to speed things up, menu will discard possibilities in
 
545
which any node has a `local' penalty of more than hint_mlpenalty.  Increase
 
546
this value if you think menu is overlooking your favorite tree (also decrease
 
547
minhintfreq), decrease this value if you think menu is wasting too much time.
 
548
Because of hint_max_ntry, the influence of this variable is nearly zero
 
549
nowadays.
 
550
</dd>
 
551
</dl>
 
552
<dl>
 
553
<dt><samp>hint_max_ntry=4</samp></dt>
 
554
<dd>
 
555
menu will recursively, for each node, try the hint_max_ntry best local
 
556
menu-divisions.
 
557
</dd>
 
558
</dl>
 
559
<dl>
 
560
<dt><samp>hints_max_iter_hint=5</samp></dt>
 
561
<dd>
 
562
The search for what hints to use in one menu is rather expensive.  But due to
 
563
the way things are sorted, menu seems to always find the `best' match in the
 
564
first 2% of iterations.  Thus, a way to speedup things is simply to cut of menu
 
565
searching after `some' iterations are done.  This value controls this, and
 
566
limits the number of iterations to
 
567
5+hint_max_iter_hint*number_of_possible_hints.  Set this value to negative to
 
568
disable this.
 
569
</dd>
 
570
</dl>
 
571
<dl>
 
572
<dt><samp>hint_debug=false</samp></dt>
 
573
<dd>
 
574
Set to true if you want to see loads and loads of debug output.
 
575
</dd>
 
576
</dl>
 
577
 
 
578
<hr>
 
579
 
 
580
<a name="s7.4"></a>
 
581
<h2>7.4 Hints, tree optimization</h2>
 
582
 
 
583
<p>
 
584
The hints actually work in a rather strange way: when
 
585
<samp>hint_optimize=true</samp> then all <samp>$section</samp> elements are
 
586
added to the specified <samp>$hints</samp> variable, and the order
 
587
(/Apps/Editors or /Editors/Apps) of the resulting hints is completely ignored.
 
588
Then, the hints for each menu entry are handed to the optimization routine,
 
589
that will calculate a reasonable tree for those hints.  That tree must comply
 
590
with the following:
 
591
 
 
592
<p>
 
593
When a user looks for a program &quot;Program&quot; with, say, hints
 
594
&quot;Good,Bulky,Heaven&quot;, then, while walking through the tree, it should
 
595
at every node visited be clear for the user what submenu to select (or the menu
 
596
should have &quot;Program&quot; directly in it).  So, the toplevel menu may
 
597
look like
 
598
 
 
599
<pre>
 
600
       Good
 
601
       Hell
 
602
       Microsoft
 
603
</pre>
 
604
 
 
605
<p>
 
606
because then a searcher for a menu entry with hints
 
607
&quot;Good,Bulky,Heaven&quot; will know to select the submenu &quot;Good&quot;.
 
608
The toplevel menu may not look like
 
609
 
 
610
<pre>
 
611
       Good
 
612
       Hell
 
613
       Heaven
 
614
</pre>
 
615
 
 
616
<p>
 
617
as now it isn't clear whether to visit the Good or the Heaven submenu.
 
618
 
 
619
<p>
 
620
That rule allows usually for many different trees, and the task of the
 
621
optimization procedure is to select, in a finite amount of time, the tree that
 
622
best matches the user's desire about the optimum number of menu entries.
 
623
 
 
624
<hr>
 
625
 
 
626
[ <a href="ch6.html">previous</a> ]
 
627
[ <a href="index.html#contents">Contents</a> ]
 
628
[ <a href="ch1.html">1</a> ]
 
629
[ <a href="ch2.html">2</a> ]
 
630
[ <a href="ch3.html">3</a> ]
 
631
[ <a href="ch4.html">4</a> ]
 
632
[ <a href="ch5.html">5</a> ]
 
633
[ <a href="ch6.html">6</a> ]
 
634
[ 7 ]
 
635
[ <a href="ch8.html">8</a> ]
 
636
[ <a href="ch8.html">next</a> ]
 
637
 
 
638
<hr>
 
639
 
 
640
<p>
 
641
Debian Menu System
 
642
 
 
643
<address>
 
644
version 1.4, 22 March 2005<br>
 
645
<br>
 
646
Joost Witteveen <code><a href="mailto:joostje@debian.org">joostje@debian.org</a></code><br>
 
647
Joey Hess <code><a href="mailto:joeyh@debian.org">joeyh@debian.org</a></code><br>
 
648
Christian Schwarz <code><a href="mailto:schwarz@debian.org">schwarz@debian.org</a></code><br>
 
649
Bill Allombert <code><a href="mailto:ballombe@debian.org">ballombe@debian.org</a></code><br>
 
650
<br>
 
651
</address>
 
652
 
 
653
<hr>
 
654
 
 
655
</body>
 
656
 
 
657
</html>
 
658