Skip to content

Commit

Permalink
118 task show menu location in the title box (#121)
Browse files Browse the repository at this point in the history
* Update config.ng.functions.sh

* added sumenu to title

* fix: typo

* added breadcrumbs to menu

* moved Breadcrumbs to title, ,revert json

* revert json

---------

Co-authored-by: Tearran <[email protected]>
  • Loading branch information
Tearran and Tearran authored Oct 6, 2024
1 parent 040586b commit f347638
Showing 1 changed file with 14 additions and 8 deletions.
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"
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

0 comments on commit f347638

Please sign in to comment.