dynamic box widths
This commit is contained in:
@ -130,33 +130,61 @@ medium1='''
|
||||
'''
|
||||
|
||||
generate_medium2_layout() {
|
||||
# Build the drive map first
|
||||
build_drive_map
|
||||
|
||||
# USB Section with dynamic mapping
|
||||
printf " External USB [0b:00.0]\n"
|
||||
printf " ┌────────┐ ┌────────┐\n"
|
||||
printf " │ %-6s │ │ %-6s │\n" "${DRIVE_MAP[usb1]:-EMPTY}" "${DRIVE_MAP[usb2]:-EMPTY}"
|
||||
printf " └────────┘ └────────┘\n\n"
|
||||
# Calculate max width needed for drive names
|
||||
max_width=0
|
||||
for bay in {1..10} "11" "usb1" "usb2"; do
|
||||
drive_text="${DRIVE_MAP[$bay]:-EMPTY}"
|
||||
text_len=$((${#bay} + 1 + ${#drive_text}))
|
||||
[[ $text_len -gt $max_width ]] && max_width=$text_len
|
||||
done
|
||||
|
||||
# Rest of chassis layout with enhanced drive info
|
||||
# Add padding for box borders
|
||||
box_width=$((max_width + 2))
|
||||
|
||||
# Create dynamic box borders
|
||||
box_top=$(printf "┌%${box_width}s┐" | tr ' ' '─')
|
||||
box_bottom=$(printf "└%${box_width}s┘" | tr ' ' '─')
|
||||
|
||||
# USB Section
|
||||
printf "\n External USB [0b:00.0]\n"
|
||||
printf " %s %s\n" "$box_top" "$box_top"
|
||||
printf " │ %-${max_width}s │ │ %-${max_width}s │\n" "${DRIVE_MAP[usb1]:-EMPTY}" "${DRIVE_MAP[usb2]:-EMPTY}"
|
||||
printf " %s %s\n\n" "$box_bottom" "$box_bottom"
|
||||
|
||||
# Main chassis section
|
||||
printf "┌──────────────────────────────────────────────────────────────┐\n"
|
||||
printf "│ B650D4U3-2Q/BCM │\n"
|
||||
printf "│ │\n"
|
||||
printf "│ NVMe [0d:00.0] Bay 11 │\n"
|
||||
printf "│ ┌─────────┐ │\n"
|
||||
printf "│ │ %-6s │ │\n" "${DRIVE_MAP[11]:-EMPTY}"
|
||||
printf "│ └─────────┘ │\n"
|
||||
printf "│ %s │\n" "$box_top"
|
||||
printf "│ │ %-${max_width}s │ │\n" "${DRIVE_MAP[11]:-EMPTY}"
|
||||
printf "│ %s │\n" "$box_bottom"
|
||||
printf "│ │\n"
|
||||
printf "│ Front Hot-swap Bays [0c:00.0] │\n"
|
||||
printf "│ ┌─────────┐┌─────────┐┌─────────┐┌─────────┐┌─────────┐┌────────┐┌────────┐┌────────┐┌────────┐┌────────┐ │\n"
|
||||
|
||||
# Create dynamic box tops for all bays
|
||||
printf "│ "
|
||||
for bay in {1..10}; do
|
||||
printf "│ │%-2d:%-4s │" "$bay" "${DRIVE_MAP[$bay]:-EMPTY}"
|
||||
printf "%s" "$box_top"
|
||||
done
|
||||
|
||||
printf " │\n"
|
||||
printf "│ └─────────┘└─────────┘└─────────┘└─────────┘└─────────┘└────────┘└────────┘└────────┘└────────┘└────────┘ │\n"
|
||||
|
||||
# Create bay labels with drives
|
||||
printf "│ "
|
||||
for bay in {1..10}; do
|
||||
printf "│%-2d:%-${max_width}s │" "$bay" "${DRIVE_MAP[$bay]:-EMPTY}"
|
||||
done
|
||||
printf " │\n"
|
||||
|
||||
# Create dynamic box bottoms for all bays
|
||||
printf "│ "
|
||||
for bay in {1..10}; do
|
||||
printf "%s" "$box_bottom"
|
||||
done
|
||||
printf " │\n"
|
||||
|
||||
printf "└──────────────────────────────────────────────────────────────┘\n"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user