xref: /freebsd/stand/forth/menu.4th.8 (revision 37798b1d5dd12cd5e842b6f99135a2e4af8cf9e0)
1ca987d46SWarner Losh.\" Copyright (c) 2011-2013 Devin Teske
2ca987d46SWarner Losh.\" All rights reserved.
3ca987d46SWarner Losh.\"
4ca987d46SWarner Losh.\" Redistribution and use in source and binary forms, with or without
5ca987d46SWarner Losh.\" modification, are permitted provided that the following conditions
6ca987d46SWarner Losh.\" are met:
7ca987d46SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
8ca987d46SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
9ca987d46SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
10ca987d46SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
11ca987d46SWarner Losh.\"    documentation and/or other materials provided with the distribution.
12ca987d46SWarner Losh.\"
13ca987d46SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14ca987d46SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15ca987d46SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16ca987d46SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17ca987d46SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18ca987d46SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19ca987d46SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20ca987d46SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21ca987d46SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22ca987d46SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23ca987d46SWarner Losh.\" SUCH DAMAGE.
24ca987d46SWarner Losh.\"
25*37798b1dSWarner Losh.Dd October 4, 2024
26ca987d46SWarner Losh.Dt MENU.4TH 8
27ca987d46SWarner Losh.Os
28ca987d46SWarner Losh.Sh NAME
29ca987d46SWarner Losh.Nm menu.4th
30ca987d46SWarner Losh.Nd FreeBSD dynamic menu boot module
31ca987d46SWarner Losh.Sh DESCRIPTION
32ca987d46SWarner LoshThe file that goes by the name of
33ca987d46SWarner Losh.Nm
34ca987d46SWarner Loshis a set of commands designed to display a dynamic menu system managed through
35ca987d46SWarner Losha system of carefully named environment variables.
36ca987d46SWarner LoshThe commands of
37ca987d46SWarner Losh.Nm
38ca987d46SWarner Loshby themselves are not enough for most uses.
39ca987d46SWarner LoshPlease refer to the
40ca987d46SWarner Loshexamples below for the most common situations, and to
41ca987d46SWarner Losh.Xr loader 8
42ca987d46SWarner Loshfor additional commands.
43ca987d46SWarner Losh.Pp
44ca987d46SWarner LoshBefore using any of the commands provided in
45ca987d46SWarner Losh.Nm ,
46ca987d46SWarner Loshit must be included
47ca987d46SWarner Loshthrough the command:
48ca987d46SWarner Losh.Pp
49ca987d46SWarner Losh.Dl include menu.4th
50ca987d46SWarner Losh.Pp
51ca987d46SWarner LoshThis line is present in the default
52ca987d46SWarner Losh.Pa /boot/menu.rc
53ca987d46SWarner Loshfile, so it is not needed (and should not be re-issued) in a normal setup.
54ca987d46SWarner Losh.Pp
55ca987d46SWarner LoshThe commands provided by it are:
56ca987d46SWarner Losh.Pp
57ca987d46SWarner Losh.Bl -tag -width disable-module_module -compact -offset indent
58ca987d46SWarner Losh.It Ic menu-init
59ca987d46SWarner LoshDraws the menu bounding box and initializes some internal state variables.
60ca987d46SWarner LoshThis should be called before any other menu-related functions.
61ca987d46SWarner Losh.It Ic menu-display
62ca987d46SWarner LoshDisplays the menu (configured via the below documented environment variables)
63ca987d46SWarner Loshand blocks on keyboard input, awaiting user action.
64ca987d46SWarner Losh.It Ic menu-erase
65ca987d46SWarner LoshClears the screen area within the menu bounding box.
66ca987d46SWarner Losh.It Ic menu-redraw
67ca987d46SWarner LoshCalls
68ca987d46SWarner Losh.Ic menu-erase
69ca987d46SWarner Loshand then redraws the menu.
70ca987d46SWarner Losh.It Ic menu-unset
71ca987d46SWarner LoshUnsets the environment variables associated with individual menu items,
72ca987d46SWarner Loshclearing the way for a new menu.
73ca987d46SWarner Losh.It Ic menu-clear
74ca987d46SWarner LoshCalls
75ca987d46SWarner Losh.Ic menu-unset
76ca987d46SWarner Loshand then
77ca987d46SWarner Losh.Ic menu-erase .
78ca987d46SWarner Losh.El
79ca987d46SWarner Losh.Pp
80ca987d46SWarner LoshThe environment variables that effect its behavior are:
81ca987d46SWarner Losh.Bl -tag -width bootfile -offset indent
82ca987d46SWarner Losh.It Va loader_color
83ca987d46SWarner LoshIf set to
84ca987d46SWarner Losh.Dq Li NO
85ca987d46SWarner Losh(case-insensitive) or
86ca987d46SWarner Losh.Dq Li 0 ,
87ca987d46SWarner Loshcauses the menu to be displayed without color.
88ca987d46SWarner LoshThe default is to use ANSI coloring whenever possible.
89ca987d46SWarner LoshIf serial boot is enabled, color is disabled by default.
90ca987d46SWarner LoshColor features include the use of ANSI bold for numbers appearing to the left
91ca987d46SWarner Loshof menuitems and the use of special
92ca987d46SWarner Losh.Dq Li ansi
93ca987d46SWarner Loshvariables described below.
94ca987d46SWarner Losh.It Va autoboot_delay
95ca987d46SWarner LoshNumber of seconds
96ca987d46SWarner Losh.Ic menu-display
97ca987d46SWarner Loshwill wait before executing
98ca987d46SWarner Losh.Va menu_timeout_command
99ca987d46SWarner Losh.Ic ( boot
100ca987d46SWarner Loshby default) unless a key is pressed.
101ca987d46SWarner LoshIf set to
102ca987d46SWarner Losh.Dq Li NO
103ca987d46SWarner Losh(case-insensitive)
104ca987d46SWarner Losh.Ic menu-display
105ca987d46SWarner Loshwill wait for user input and never execute
106ca987d46SWarner Losh.Ic menu_timeout_command .
107ca987d46SWarner LoshIf set to
108ca987d46SWarner Losh.Dq Li -1 ,
109ca987d46SWarner Losh.Ic menu-display
110ca987d46SWarner Loshwill boot immediately, preventing both interruption of the
111ca987d46SWarner Losh.Ic autoboot
112ca987d46SWarner Loshprocess and escaping to the loader prompt.
113ca987d46SWarner LoshDefault is
114ca987d46SWarner Losh.Dq Li 10 .
115ca987d46SWarner LoshSee
116ca987d46SWarner Losh.Xr loader 8
117ca987d46SWarner Loshfor additional information.
118ca987d46SWarner Losh.It Va menu_timeout_command
119ca987d46SWarner LoshThe command to be executed after
120ca987d46SWarner Losh.Va autoboot_delay
121ca987d46SWarner Loshseconds if a key is not pressed.
122ca987d46SWarner LoshThe default is
123ca987d46SWarner Losh.Ic boot .
124ca987d46SWarner Losh.It Va loader_menu_frame
125ca987d46SWarner LoshSets the desired box style to draw around the boot menu.
126ca987d46SWarner LoshPossible values are:
127ca987d46SWarner Losh.Dq Li single
128ca987d46SWarner Losh.Pq the default ,
129ca987d46SWarner Losh.Dq Li double ,
130ca987d46SWarner Loshand
131ca987d46SWarner Losh.Dq Li none .
132ca987d46SWarner Losh.It Va loader_menu_timeout_x
133ca987d46SWarner LoshSets the desired column position of the timeout countdown text.
134ca987d46SWarner LoshDefault is 4.
135ca987d46SWarner Losh.It Va loader_menu_timeout_y
136ca987d46SWarner LoshSets the desired row position of the timeout countdown text.
137ca987d46SWarner LoshDefault is 23.
138ca987d46SWarner Losh.It Va loader_menu_title
139ca987d46SWarner LoshThe text to display above the menu.
140ca987d46SWarner LoshDefault is
141ca987d46SWarner Losh.Dq Li "Welcome to FreeBSD" .
142ca987d46SWarner Losh.It Va loader_menu_title_align
143ca987d46SWarner LoshDefault is to align
144ca987d46SWarner Losh.Ic loader_menu_title
145ca987d46SWarner Loshcentered above the menu. This can be set to
146ca987d46SWarner Losh.Dq Li left
147ca987d46SWarner Loshor
148ca987d46SWarner Losh.Dq Li right
149ca987d46SWarner Loshto instead display the title left-or-right justified
150ca987d46SWarner Losh.Pq respectively .
151ca987d46SWarner Losh.It Va loader_menu_x
152ca987d46SWarner LoshSets the desired column position of the boot menu.
153ca987d46SWarner LoshDefault is 5.
154ca987d46SWarner Losh.It Va loader_menu_y
155ca987d46SWarner LoshSets the desired row position of the boot menu.
156ca987d46SWarner LoshDefault is 10.
157ca987d46SWarner Losh.It Va menu_caption[x]
158ca987d46SWarner LoshThe text to be displayed for the numbered menuitem
159ca987d46SWarner Losh.Dq Li x .
160ca987d46SWarner Losh.It Va menu_command[x]
161ca987d46SWarner LoshThe command to be executed when the number associated with menuitem
162ca987d46SWarner Losh.Dq Li x
163ca987d46SWarner Loshis pressed.
164ca987d46SWarner LoshSee the list of included FICL words below for some ideas.
165ca987d46SWarner Losh.It Va menu_keycode[x]
166ca987d46SWarner LoshAn optional decimal ASCII keycode to be associated with menuitem
167ca987d46SWarner Losh.Dq Li x .
168ca987d46SWarner LoshWhen pressed, will cause the execution of
169ca987d46SWarner Losh.Va menu_command[x] .
170ca987d46SWarner Losh.It Va ansi_caption[x]
171ca987d46SWarner LoshIf
172ca987d46SWarner Losh.Va loader_color
173ca987d46SWarner Loshis set
174ca987d46SWarner Losh.Pq enabled by default ,
175ca987d46SWarner Loshuse this caption for menuitem
176ca987d46SWarner Losh.Dq Li x
177ca987d46SWarner Loshinstead of
178ca987d46SWarner Losh.Va menu_caption[x] .
179ca987d46SWarner Losh.It Va toggled_text[x]
180ca987d46SWarner LoshFor menuitems where
181ca987d46SWarner Losh.Va menu_command[x]
182ca987d46SWarner Loshis set to
183ca987d46SWarner Losh.Dq Li toggle_menuitem
184ca987d46SWarner Losh(or a derivative thereof), the text displayed
185ca987d46SWarner Loshwill toggle between this and
186ca987d46SWarner Losh.Va menu_caption[x] .
187ca987d46SWarner Losh.It Va toggled_ansi[x]
188ca987d46SWarner LoshLike
189ca987d46SWarner Losh.Va toggled_text[x]
190ca987d46SWarner Loshexcept used when
191ca987d46SWarner Losh.Va loader_color
192ca987d46SWarner Loshis enabled
193ca987d46SWarner Losh.Pq default .
194ca987d46SWarner Losh.It Va menu_caption[x][y]
195ca987d46SWarner LoshFor menuitems where
196ca987d46SWarner Losh.Va menu_command[x]
197ca987d46SWarner Loshis set to
198ca987d46SWarner Losh.Dq Li cycle_menuitem
199ca987d46SWarner Losh(or a derivative thereof), the text displayed will cycle between this and other
200ca987d46SWarner Losh.Va menu_caption[x][y]
201ca987d46SWarner Loshentries.
202ca987d46SWarner Losh.It Va ansi_caption[x][y]
203ca987d46SWarner LoshLike
204ca987d46SWarner Losh.Va menu_caption[x][y]
205ca987d46SWarner Loshexcept used when
206ca987d46SWarner Losh.Va loader_color
207ca987d46SWarner Loshis enabled
208ca987d46SWarner Losh.Pq default .
209ca987d46SWarner Losh.It Va menu_acpi
210ca987d46SWarner LoshWhen set to a number
211ca987d46SWarner Losh.Dq Li x
212ca987d46SWarner Loshassociated with a given menuitem, that menuitem will only appear when
213*37798b1dSWarner Loshrunning on ACPI-compatible hardware,
214*37798b1dSWarner Losh.Va acpi.rsdp
215ca987d46SWarner Loshis set (indicating the presence of hardware ACPI support as detected by
216ca987d46SWarner Losh.Xr loader 8 ) ,
217ca987d46SWarner Loshand
218ca987d46SWarner Losh.Va hint.acpi.0.disabled
219ca987d46SWarner Loshis not set.
220ca987d46SWarner LoshOn non-i386 hardware, menuitems configured after the
221ca987d46SWarner Losh.Dq Li menu_acpi
222ca987d46SWarner Loshmenuitem will use a lower number (to compensate for the missing ACPI menuitem)
223ca987d46SWarner Loshbut continue to function as expected.
224ca987d46SWarner LoshOn i386-compatible hardware lacking ACPI support (as detected by
225ca987d46SWarner Losh.Xr loader 8 ) ,
226ca987d46SWarner Loshsubsequent menuitems will retain their associated numbers.
227*37798b1dSWarner Losh.It Va acpi.rsdp
228ca987d46SWarner LoshSet automatically by
229ca987d46SWarner Losh.Xr loader 8
230*37798b1dSWarner Loshon ACPI-compatible hardware when ACPI support is detected at boot time.
231ca987d46SWarner LoshEffects the display of the
232ca987d46SWarner Losh.Dq Li menu_acpi
233ca987d46SWarner Loshmenuitem (if configured).
234ca987d46SWarner Losh.It Va hint.acpi.0.disabled
235ca987d46SWarner LoshEffects the display of the
236ca987d46SWarner Losh.Va menu_acpi
237ca987d46SWarner Loshmenuitem.
238ca987d46SWarner LoshIf set, the menuitem will display
239ca987d46SWarner Losh.Va toggled_text[x]
240ca987d46SWarner Losh.Va ( toggled_ansi[x]
241ca987d46SWarner Loshif
242ca987d46SWarner Losh.Va loader_color
243ca987d46SWarner Loshis set), otherwise
244ca987d46SWarner Losh.Va menu_caption[x]
245ca987d46SWarner Losh.Va ( ansi_caption[x]
246ca987d46SWarner Loshif
247ca987d46SWarner Losh.Va loader_color
248ca987d46SWarner Loshis set).
249ca987d46SWarner Losh.It Va menu_options
250ca987d46SWarner LoshWhen set to a number
251ca987d46SWarner Losh.Dq Li x ,
252ca987d46SWarner Losha single blank-line and an
253ca987d46SWarner Losh.Dq Li Options
254ca987d46SWarner Loshheader are inserted between
255ca987d46SWarner Losh.Va menu_caption[x-1]
256ca987d46SWarner Loshand
257ca987d46SWarner Losh.Va menu_caption[x]
258ca987d46SWarner Losh(if configured).
259ca987d46SWarner Losh.It Va menu_reboot
260ca987d46SWarner LoshIf set, adds a built-in
261ca987d46SWarner Losh.Dq Li Reboot
262ca987d46SWarner Loshmenuitem to the end of the last configured menuitem.
263ca987d46SWarner LoshIf
264ca987d46SWarner Losh.Va menu_options
265ca987d46SWarner Loshis configured, the
266ca987d46SWarner Losh.Dq Li Reboot
267ca987d46SWarner Loshmenuitem will be inserted before the
268ca987d46SWarner Losh.Dq Options
269ca987d46SWarner Loshseparator.
270ca987d46SWarner Losh.El
271ca987d46SWarner Losh.Pp
272ca987d46SWarner LoshIn addition, it provides the following FICL words:
273ca987d46SWarner Losh.Pp
274ca987d46SWarner Losh.Bl -tag -width disable-module_module -compact -offset indent
275ca987d46SWarner Losh.It Ic arch-i386? ( -- BOOL )
276ca987d46SWarner LoshReturns true (-1) on i386 and false (0) otherwise.
277ca987d46SWarner Losh.It Ic acpipresent? ( -- BOOL )
278ca987d46SWarner LoshReturns true (-1) if ACPI is present and false (0) otherwise.
279ca987d46SWarner Losh.It Ic acpienabled? ( -- BOOL )
280ca987d46SWarner LoshReturns true (-1) if ACPI is enabled and false (0) otherwise.
281ca987d46SWarner Losh.It Ic toggle_menuitem ( N -- N )
282ca987d46SWarner LoshToggles menuitem
283ca987d46SWarner Losh.Dq Li N
284ca987d46SWarner Loshbetween
285ca987d46SWarner Losh.Va menu_caption[x]
286ca987d46SWarner Loshand
287ca987d46SWarner Losh.Va toggled_text[x]
288ca987d46SWarner Losh(where
289ca987d46SWarner Losh.Dq Li N
290ca987d46SWarner Loshrepresents the ASCII decimal value for
291ca987d46SWarner Losh.Dq Li x ) .
292ca987d46SWarner Losh.It Ic cycle_menuitem ( N -- N )
293ca987d46SWarner LoshCycles menuitem
294ca987d46SWarner Losh.Dq Li N
295ca987d46SWarner Loshbetween
296ca987d46SWarner Losh.Va menu_caption[x][y]
297ca987d46SWarner Loshentries (where
298ca987d46SWarner Losh.Va N
299ca987d46SWarner Loshrepresents the ASCII decimal value for
300ca987d46SWarner Losh.Va x ) .
301ca987d46SWarner Losh.El
302ca987d46SWarner Losh.Pp
303ca987d46SWarner LoshFor all values of
304ca987d46SWarner Losh.Dq Li x
305ca987d46SWarner Loshabove, use any number between 1 through 9. Sorry, double-digits are not
306ca987d46SWarner Loshcurrently supported.
307ca987d46SWarner Losh.Sh FILES
308ca987d46SWarner Losh.Bl -tag -width /boot/loader.4th -compact
309ca987d46SWarner Losh.It Pa /boot/loader
310ca987d46SWarner LoshThe
311ca987d46SWarner Losh.Xr loader 8 .
312ca987d46SWarner Losh.It Pa /boot/menu.4th
313ca987d46SWarner Losh.Nm
314ca987d46SWarner Loshitself.
315ca987d46SWarner Losh.It Pa /boot/loader.rc
316ca987d46SWarner Losh.Xr loader 8
317ca987d46SWarner Loshbootstrapping script.
318ca987d46SWarner Losh.El
319ca987d46SWarner Losh.Sh EXAMPLES
320ca987d46SWarner LoshA simple boot menu:
321ca987d46SWarner Losh.Pp
322ca987d46SWarner Losh.Bd -literal -offset indent -compact
323ca987d46SWarner Loshinclude /boot/menu.4th
324ca987d46SWarner Loshmenu-init
325ca987d46SWarner Loshset menu_caption[1]="Boot"
326ca987d46SWarner Loshset menu_command[1]="boot"
327ca987d46SWarner Loshset menu_options=2
328ca987d46SWarner Loshset menu_caption[2]="Option: NO"
329ca987d46SWarner Loshset toggled_text[2]="Option: YES"
330ca987d46SWarner Loshset menu_command[2]="toggle_menuitem"
331ca987d46SWarner Loshset menu_timeout_command="boot"
332ca987d46SWarner Loshset menu_reboot
333ca987d46SWarner Loshmenu-display
334ca987d46SWarner Losh.Ed
335ca987d46SWarner Losh.Sh SEE ALSO
336ca987d46SWarner Losh.Xr loader.conf 5 ,
337ca987d46SWarner Losh.Xr beastie.4th 8 ,
338ca987d46SWarner Losh.Xr loader 8 ,
339ca987d46SWarner Losh.Xr loader.4th 8
340ca987d46SWarner Losh.Sh HISTORY
341ca987d46SWarner LoshThe
342ca987d46SWarner Losh.Nm
343ca987d46SWarner Loshset of commands first appeared in
344ca987d46SWarner Losh.Fx 9.0 .
345ca987d46SWarner Losh.Sh AUTHORS
346ca987d46SWarner LoshThe
347ca987d46SWarner Losh.Nm
348ca987d46SWarner Loshset of commands was written by
349ca987d46SWarner Losh.An -nosplit
350ca987d46SWarner Losh.An Devin Teske Aq dteske@FreeBSD.org .
351