2023-09-30 12:46:03 +00:00
|
|
|
function menu {
|
|
|
|
if [ "${1}" ] ; then
|
2023-09-30 17:52:10 +00:00
|
|
|
menu_load "${1}"
|
2023-09-30 12:46:03 +00:00
|
|
|
else
|
2023-11-22 21:56:22 +00:00
|
|
|
export menu
|
2023-09-30 17:52:10 +00:00
|
|
|
menu_load "${menu}"
|
2023-09-30 12:46:03 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function menu_color {
|
2023-11-23 18:29:33 +00:00
|
|
|
setparams \
|
2023-09-30 12:46:03 +00:00
|
|
|
'black' 'blue' 'green' 'cyan' \
|
|
|
|
'red' 'magenta' 'brown' 'light-gray' \
|
|
|
|
'dark-gray' 'light-blue' 'light-green' 'light-cyan' \
|
|
|
|
'light-red' 'light-magenta' 'yellow' 'white'
|
2023-11-23 18:29:33 +00:00
|
|
|
for color in "${@}" ; do
|
|
|
|
menu_item "${color}"
|
|
|
|
done
|
|
|
|
unset color
|
|
|
|
}
|
|
|
|
|
|
|
|
function menu_exit {
|
|
|
|
env save
|
|
|
|
menu
|
2023-09-30 12:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function menu_init {
|
2023-11-10 19:09:15 +00:00
|
|
|
env_init
|
2023-10-01 17:59:50 +00:00
|
|
|
if [ "${menu}" ] ; then
|
|
|
|
if [ "${1}" ] ; then
|
|
|
|
menuentry "→ ${menu} → ${1}" { nop }
|
|
|
|
else
|
|
|
|
menuentry "→ ${menu}" { nop }
|
|
|
|
fi
|
|
|
|
menu_split
|
|
|
|
default=2
|
2023-11-23 18:29:33 +00:00
|
|
|
if env_get "${menu}" ; then
|
|
|
|
default="_${get}"
|
|
|
|
unset get
|
|
|
|
fi
|
2023-09-30 12:46:03 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function menu_item {
|
2023-11-23 18:29:33 +00:00
|
|
|
if [ "${1}" ] ; then
|
|
|
|
if [ "${2}" ] ; then
|
|
|
|
entry="${2}"
|
|
|
|
else
|
|
|
|
entry="${1}"
|
|
|
|
fi
|
|
|
|
menuentry "${entry}" "${1}" "${menu}" --id "_${1}" {
|
|
|
|
${3}="${2}"
|
|
|
|
menu_exit
|
2023-09-30 12:46:03 +00:00
|
|
|
}
|
2023-11-23 18:29:33 +00:00
|
|
|
unset entry
|
|
|
|
fi
|
2023-09-30 12:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function menu_load {
|
|
|
|
menu="${1}"
|
2023-09-30 17:52:10 +00:00
|
|
|
export menu
|
|
|
|
configfile "${live}/menu/${menu}.sh"
|
2023-09-30 12:46:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function menu_split {
|
2023-09-30 17:52:10 +00:00
|
|
|
if [ "${1}" ] ; then
|
|
|
|
menuentry '' --id "${1}" { nop }
|
|
|
|
else
|
|
|
|
menuentry '' { nop }
|
|
|
|
fi
|
2023-09-30 12:46:03 +00:00
|
|
|
}
|
2023-11-23 18:29:33 +00:00
|
|
|
|
|
|
|
function menu_swap {
|
|
|
|
if [ "${4}" ] ; then
|
|
|
|
menuentry "${1}" "${2}" "${3}" "${4}" {
|
|
|
|
if env_get "${2}" ; then
|
|
|
|
if [ "${get}" == "${3}" ] ; then
|
|
|
|
${2}="${4}"
|
|
|
|
else
|
|
|
|
${2}="${3}"
|
|
|
|
fi
|
|
|
|
unset get
|
|
|
|
menu_exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
}
|