Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

118 task show menu location in the title box #121

Merged
merged 9 commits into from
Oct 6, 2024
22 changes: 14 additions & 8 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function set_runtime_variables() {
[[ -z "${ARMBIAN// /}" ]] && ARMBIAN="$DISTRO $DISTROID"
DEFAULT_ADAPTER=$(ip -4 route ls | grep default | tail -1 | grep -Po '(?<=dev )(\S+)')
LOCALIPADD=$(ip -4 addr show dev $DEFAULT_ADAPTER | awk '/inet/ {print $2}' | cut -d'/' -f1)
BACKTITLE="\n Contribute: https://github.com/armbian/configng\n"
Tearran marked this conversation as resolved.
Show resolved Hide resolved
BACKTITLE="Contribute: https://github.com/armbian/configng"
TITLE="Armbian configuration utility"
[[ -z "${DEFAULT_ADAPTER// /}" ]] && DEFAULT_ADAPTER="lo"

Expand Down Expand Up @@ -528,14 +528,17 @@ module_options+=(
# Function to generate the main menu from a JSON object
#
generate_top_menu() {
local json_data=$1
local json_data="$1"
local status="$ARMBIAN $KERNELID ($DISTRO $DISTROID)"
local backtitle="$BACKTITLE"


while true; do
local menu_options=()

parse_menu_items menu_options

local OPTION=$($DIALOG --title "$TITLE" --menu "$BACKTITLE" 0 80 9 "${menu_options[@]}" \
local OPTION=$($DIALOG --backtitle "$backtitle" --title "$TITLE" --menu "$status" 0 80 9 "${menu_options[@]}" \
--ok-button Select --cancel-button Exit 3>&1 1>&2 2>&3)
local exitstatus=$?

Expand All @@ -548,7 +551,7 @@ generate_top_menu() {
}

module_options+=(
["generate_menu,author"]="Joey Turner"
["generate_menu,author"]="Tearran"
["generate_menu,ref_link"]=""
["generate_menu,feature"]="generate_menu"
["generate_menu,desc"]="Generate a submenu from a parent_id"
Expand All @@ -560,14 +563,17 @@ module_options+=(
# Function to generate the submenu
#
function generate_menu() {
local parent_id=$1
local parent_id="$1"
local top_parent_id="$2"
local backtitle="$BACKTITLE"
local status=""

while true; do
# Get the submenu options for the current parent_id
local submenu_options=()
parse_menu_items submenu_options

local OPTION=$($DIALOG --title "$TITLE" --menu "$BACKTITLE" 0 80 9 "${submenu_options[@]}" \
local OPTION=$($DIALOG --backtitle "$BACKTITLE" --title "$top_parent_id $parent_id" --menu "$status" 0 80 9 "${submenu_options[@]}" \
--ok-button Select --cancel-button Back 3>&1 1>&2 2>&3)

local exitstatus=$?
Expand All @@ -581,7 +587,7 @@ function generate_menu() {
if [ "$submenu_count" -gt 0 ]; then
# If it does, generate a new menu for the submenu
[[ -n "$debug" ]] && echo "$OPTION"
generate_menu "$OPTION"
generate_menu "$OPTION" "$parent_id"
else
# If it doesn't, execute the command
[[ -n "$debug" ]] && echo "$OPTION"
Expand Down Expand Up @@ -722,7 +728,7 @@ show_menu() {
done <<< "$input"

# Display the menu and get the user's choice
[[ $DIALOG != "bash" ]] && choice=$($DIALOG --title "Menu" --menu "Choose an option:" 0 0 9 "${options[@]}" 3>&1 1>&2 2>&3)
[[ $DIALOG != "bash" ]] && choice=$($DIALOG --title "$TITLE" --menu "Choose an option:" 0 0 9 "${options[@]}" 3>&1 1>&2 2>&3)

# Check if the user made a choice
if [ $? -eq 0 ]; then
Expand Down