|
4 | 4 | # MiOS live system dashboard. Renders to ANY tty -- detects color |
5 | 5 | # capability, degrades to plain ASCII on tty0 / `linux` console. |
6 | 6 | # |
7 | | -# Everything renders inside an 80-column frame so output never bleeds |
8 | | -# past a tty0/console viewport. Long lines are truncated with an |
9 | | -# ellipsis (default) or marquee-scrolled when --ticker is passed. |
| 7 | +# Everything renders inside a frame whose width comes from |
| 8 | +# /usr/share/mios/mios.toml [terminal].cols - [terminal].right_margin |
| 9 | +# (default 80, edge-to-edge), so output never bleeds past the tty0 / |
| 10 | +# console viewport. Long lines are truncated with an ellipsis (default) |
| 11 | +# or marquee-scrolled when --ticker is passed. |
10 | 12 | # |
11 | 13 | # Modes: |
12 | 14 | # default : framed header (ASCII art) + fastfetch + services + loop hint |
|
18 | 20 | # blocks until Ctrl-C, so NOT used in motd path) |
19 | 21 | # --no-frame : disable the outer frame (legacy / debug) |
20 | 22 | # |
21 | | -# Frame dimensions are FIXED at 80 cols wide. The Windows desktop |
22 | | -# launcher (build-mios.ps1's Install-WindowsBranding) sizes its |
23 | | -# Windows Terminal profile to match exactly. |
| 23 | +# Frame dimensions are sourced from /usr/share/mios/mios.toml [terminal] |
| 24 | +# (cols, right_margin) -- WIDTH = cols - right_margin, edge-to-edge by |
| 25 | +# default (cols=80, right_margin=0 -> WIDTH=80). Set MIOS_TOML to point |
| 26 | +# the awk helper at a different TOML file (e.g. for testing). The |
| 27 | +# Windows desktop launcher (build-mios.ps1's Install-WindowsBranding) |
| 28 | +# reads the same [terminal] keys via its own PowerShell TOML reader, |
| 29 | +# so cross-platform values stay aligned. |
24 | 30 | # |
25 | 31 | # Entry points: |
26 | 32 | # - /etc/profile.d/zz-mios-motd.sh runs the default mode at every |
|
77 | 83 | F_LT="+"; F_RT="+"; F_V="|" |
78 | 84 | fi |
79 | 85 |
|
80 | | -# ── Frame dimensions (FIXED 80 cols) ───────────────────────────────────────── |
81 | | -# 80 = tty0 native width and the Windows Terminal MiOS profile size. |
82 | | -# Inner width = 76: "│ " (2) + content + " │" (2) = 80. |
83 | | -WIDTH=80 |
| 86 | +# ── Frame dimensions (sourced from mios.toml [terminal]) ───────────────────── |
| 87 | +# WIDTH = cols - right_margin. EDGE-TO-EDGE by default |
| 88 | +# (right_margin=0, frame_width=cols=80). The TOML is the SSOT -- |
| 89 | +# mios.html edits flow here on next render. Vendor fallback is |
| 90 | +# 80 cols / margin 0 if the TOML is missing (cold first-boot before |
| 91 | +# /usr/share/mios is staged). Inner width = WIDTH - 4 because the |
| 92 | +# frame chars consume "│ " + content + " │" = 4 cells. |
| 93 | +# |
| 94 | +# All MiOS consoles (Linux tty0, GNOME terminal, Ptyxis, WT MiOS |
| 95 | +# profile, conhost fallback, WSL pwsh dispatcher) honor the same |
| 96 | +# [terminal].cols / right_margin via their respective TOML readers |
| 97 | +# (Get-MiOS.ps1's Get-MiosTomlValue / mios-dash.ps1's regex / this |
| 98 | +# awk helper). No hardcoded 80 anywhere -- if you find one, lift it. |
| 99 | +_mios_toml_value() { |
| 100 | + local section="$1" key="$2" default="$3" |
| 101 | + local toml="${MIOS_TOML:-/usr/share/mios/mios.toml}" |
| 102 | + [[ -r "$toml" ]] || { printf '%s' "$default"; return; } |
| 103 | + awk -v want_section="$section" -v want_key="$key" -v default="$default" ' |
| 104 | + BEGIN { in_section = 0; found = 0 } |
| 105 | + /^\[/ { |
| 106 | + line = $0 |
| 107 | + sub(/[[:space:]]*#.*$/, "", line) |
| 108 | + in_section = (line == "[" want_section "]") ? 1 : 0 |
| 109 | + next |
| 110 | + } |
| 111 | + in_section && /^[[:space:]]*[A-Za-z_][A-Za-z0-9_]*[[:space:]]*=/ { |
| 112 | + line = $0 |
| 113 | + sub(/[[:space:]]*#.*$/, "", line) |
| 114 | + eq = index(line, "=") |
| 115 | + if (eq == 0) next |
| 116 | + k = substr(line, 1, eq - 1) |
| 117 | + v = substr(line, eq + 1) |
| 118 | + gsub(/^[[:space:]]+|[[:space:]]+$/, "", k) |
| 119 | + gsub(/^[[:space:]]+|[[:space:]]+$/, "", v) |
| 120 | + gsub(/^"|"$/, "", v) |
| 121 | + if (k == want_key) { print v; found = 1; exit } |
| 122 | + } |
| 123 | + END { if (!found) print default } |
| 124 | + ' "$toml" |
| 125 | +} |
| 126 | +_mios_cols=$(_mios_toml_value "terminal" "cols" "80") |
| 127 | +_mios_rmgn=$(_mios_toml_value "terminal" "right_margin" "0") |
| 128 | +WIDTH=$(( _mios_cols - _mios_rmgn )) |
| 129 | +(( WIDTH < 20 )) && WIDTH=80 # safety floor: malformed TOML / negative math |
84 | 130 | INNER=$((WIDTH - 4)) |
85 | 131 |
|
86 | 132 | # Identity from install.env (written by mios-bootstrap at install time). |
|
0 commit comments