|
NAMEmenu.lua —
FreeBSD dynamic menu boot module
DESCRIPTIONmenu.lua contains the main functionality required to
build a dynamic menu system. It also contains definitions for the built-in
menus, some of which are influenced by
loader(8)
environment variables.
Before hooking into the functionality provided by
local menu =
require("menu") MENU DEFINITIONSMenus are represented inmenu.lua as a table. That table
must contain an entries key.
If the value of the entries key is itself a table, then each value in this table defines a single entry in this menu. See MENU ITEM DEFINITIONS for the structure of each entry. entries may also be a function. This function must return a table, each value of which defines a single entry in this menu. See MENU ITEM DEFINITIONS. MENU ITEM DEFINITIONSThe following keys may be defined for a menu item:
MENU ITEM TYPESThe menu item type constants are defined in core.lua(8). The following types are available:
EXPORTED MENUSThe following menus are exported bymenu.lua :
EXAMPLESTo replace the default boot menu with a simple boot menu:local core = require("core") local menu = require("menu") menu.default = { entries = { { entry_type = core.MENU_ENTRY, name = "Boot", func = core.boot, }, { entry_type = core.MENU_CAROUSEL_ENTRY, carousel_id = "unique_boot_entry_name", items = {"NO", "YES"}, name = function(_, choice, _) return "Option: " .. choice end, func = function(_, _, _) loader.setenv("some_envvar", "some_value") end, }, }, } To add another option to the welcome menu: local core = require("core") local menu = require("menu") local welcome_entries = menu.welcome.all_entries welcome_entries[#welcome_entries + 1] = { entry_type = core.MENU_CAROUSEL_ENTRY, carousel_id = "unique_boot_entry_name", items = {"NO", "YES"}, name = function(_, choice, _) return "Option: " .. choice end, func = function(_, _, _) loader.setenv("some_envvar", "some_value") end, } SEE ALSOloader.conf(5), core.lua(8), loader(8)HISTORYThemenu.lua file first appeared in
FreeBSD 12.0.
AUTHORSThemenu.lua file was originally written by
Pedro Souza
<pedrosouza@FreeBSD.org>.
Later work and this manual page was done by
Kyle Evans <kevans@FreeBSD.org>.
Visit the GSP FreeBSD Man Page Interface. |