#!/bin/bash # ODS — ASCII QR Code Generator # Generates simple QR codes for terminal display without external dependencies # ═══════════════════════════════════════════════════════════════ # QR CODE DISPLAY # ═══════════════════════════════════════════════════════════════ # Best-effort LAN IP detection for remote access URLs. _ods_lan_ip() { local lan_ip="" if command -v ip >/dev/null 2>&1; then lan_ip=$(ip route get 1 2>/dev/null | awk '{print $7; exit}') fi if [[ -z "$lan_ip" ]] && command -v ifconfig >/dev/null 2>&1; then lan_ip=$(ifconfig 2>/dev/null | awk '/inet / && $2 != "127.0.0.1" {print $2; exit}') fi printf '%s' "$lan_ip" } # Print a QR code for the dashboard URL # Falls back to plain text if qrencode not available print_dashboard_qr() { local display_url="${1:-}" if [[ -z "$display_url" ]]; then local lan_ip lan_ip=$(_ods_lan_ip) display_url="http://${lan_ip:-localhost}:3001" fi echo "" # Try qrencode if available if command -v qrencode >/dev/null 2>&1; then echo -e " ${BOLD}Scan to open Dashboard:${NC}" echo "" qrencode -t ANSIUTF8 -m 2 "$display_url" | sed 's/^/ /' echo "" echo -e " ${CYAN}$display_url${NC}" else # Fallback: Simple ASCII box with URL print_url_box "$display_url" fi } # Print a stylish URL box (fallback when qrencode unavailable) print_url_box() { local url=$1 local url_len=${#url} local box_width=$((url_len + 6)) # Build horizontal line local hline="" for ((i=0; i