Skip to content

Commit b0e787f

Browse files
committed
shell startup: dispatch mios.toml verb instead of inline mios-dashboard.sh
Cross-platform parity with mios-bootstrap commit 19a43af. zz-mios-motd.sh rewritten as a thin verb dispatcher: - Reads [terminal.startup].linux -> .verb from layered mios.toml (~/.config > /etc/mios > /usr/share/mios; vendor fallback "mini"). - Calls `mios <verb>` (function defined in mios-verbs.sh) instead of invoking /usr/libexec/mios/mios-dashboard.sh directly. - Same skip-conditions retained (PS1, TTY, MIOS_MOTD_SHOWN, TMUX, STY, MIOS_SKIP_MOTD). mios-verbs.sh: added `mini` verb + upgraded `dash` verb: - mini: MIOS_DASH_SERVICES=0 path -> compact framed banner + fastfetch, fits in the 80x20 portal. This is what fires on every shell spawn via zz-mios-motd.sh. - dash: MIOS_DASH_SERVICES=1 + MIOS_COMPACT=0 path -> full ASCII banner + Quadlet service status + endpoint health + git working-tree state. Operator-triggered explicitly; doesn't fit in 80x20 so NOT auto-fired. - help text reflects the split. Operator 2026-05-10: profile bodies are JUST function definitions; what shows up on terminal spawn is whatever verb mios.toml points at. ALL platforms globally, ONE TOML section = SSOT.
1 parent 02b3dae commit b0e787f

2 files changed

Lines changed: 116 additions & 15 deletions

File tree

etc/profile.d/mios-verbs.sh

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,45 @@
2121

2222
mios() {
2323
case "${1:-help}" in
24+
mini)
25+
shift
26+
# MINI dashboard -- compact framed banner + fastfetch row
27+
# set, fits inside the 80x20 portal. Auto-fired on every
28+
# interactive shell spawn via /etc/profile.d/zz-mios-motd.sh
29+
# which dispatches the verb declared in
30+
# mios.toml [terminal.startup].linux (vendor default = mini).
31+
# Operator 2026-05-10: "have launch be the mini-dashboard
32+
# ... NOT PRINT ON LAUNCH" -- the dotfile fires this verb,
33+
# the verb's command output is what renders.
34+
local _dash=""
35+
for _c in /usr/libexec/mios/mios-dashboard.sh \
36+
/mnt/m/usr/libexec/mios/mios-dashboard.sh; do
37+
[[ -x "$_c" ]] && { _dash="$_c"; break; }
38+
done
39+
if [[ -n "$_dash" ]]; then
40+
# Force compact + skip services to stay inside 80x20.
41+
MIOS_DASH_SERVICES=0 "$_dash" "$@"
42+
else
43+
echo "mios mini: mios-dashboard.sh not found" >&2
44+
return 127
45+
fi
46+
;;
2447
dash|dashboard)
2548
shift
26-
if [[ -x /usr/libexec/mios/mios-dashboard.sh ]]; then
27-
/usr/libexec/mios/mios-dashboard.sh "$@"
28-
elif [[ -x /mnt/m/usr/libexec/mios/mios-dashboard.sh ]]; then
29-
/mnt/m/usr/libexec/mios/mios-dashboard.sh "$@"
49+
# FULL dashboard -- ASCII banner + fastfetch + Quadlet
50+
# service status + git/working-tree state + endpoint
51+
# health. Operator-triggered explicitly; doesn't fit in
52+
# 80x20 so NOT auto-fired on shell spawn.
53+
local _dash=""
54+
for _c in /usr/libexec/mios/mios-dashboard.sh \
55+
/mnt/m/usr/libexec/mios/mios-dashboard.sh; do
56+
[[ -x "$_c" ]] && { _dash="$_c"; break; }
57+
done
58+
if [[ -n "$_dash" ]]; then
59+
# Force the full path: services block + non-compact
60+
# ASCII banner + extended sys info. mios-dashboard.sh
61+
# already supports this via env toggles.
62+
MIOS_DASH_SERVICES=1 MIOS_COMPACT=0 "$_dash" "$@"
3063
else
3164
echo "mios dash: mios-dashboard.sh not found" >&2
3265
return 127
@@ -85,7 +118,8 @@ mios() {
85118
cat <<'EOH'
86119
87120
MiOS verbs (inside MiOS-DEV):
88-
mios dash -- show the MiOS dashboard (framed banner + fastfetch)
121+
mios mini -- compact 80x20 framed banner + fastfetch (auto on shell spawn)
122+
mios dash -- FULL dashboard: ASCII banner + services + extended sys specs
89123
mios build -- run /usr/libexec/mios/mios-build-driver (OCI image build)
90124
mios config -- launch the configurator (mios.html in default browser)
91125
mios dev -- nested bash session (you're already in MiOS-DEV)

etc/profile.d/zz-mios-motd.sh

Lines changed: 77 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
# /etc/profile.d/zz-mios-motd.sh
22
#
3-
# MiOS MOTD trigger -- runs the live system dashboard once per
4-
# interactive shell session at login. The `zz-` prefix forces this to
5-
# sort last in /etc/profile.d/, so /etc/profile.d/mios-env.sh has
6-
# already exported MIOS_* env vars by the time we render.
3+
# MiOS interactive-shell startup verb dispatcher. The dotfile is a
4+
# THIN wrapper -- it does NOT inline-print anything. Whatever shows
5+
# up on terminal spawn is the verb declared in mios.toml
6+
# [terminal.startup].linux (vendor default = "mini"). Operator
7+
# 2026-05-10: "have the bash and pwsh/WT environment/dotfile(s)
8+
# automatically run mios dash on open/launch--NOT PRINT ON LAUNCH!!!
9+
# THE ACTUAL ENV/DOTFILE(S) SHOULD DICTATE THE COMMANDS/VERBS AND
10+
# WHATS RUN ON CONSOLE SPAWN(ALL PLATFORMS GLOBALLY)--ALL SOURCED
11+
# FROM THE MIOS.TOML"
12+
#
13+
# Cross-platform parity: the Windows pwsh profile body has the same
14+
# dispatch, reading [terminal.startup].windows from the same TOML.
15+
# Both default to "mini" (compact framed dashboard). The FULL
16+
# `mios dash` render (ASCII banner + services + sys specs) is NOT
17+
# auto-fired -- operators run it explicitly when they want it.
18+
#
19+
# The `zz-` prefix forces this to sort last in /etc/profile.d/, so
20+
# /etc/profile.d/mios-env.sh + /etc/profile.d/mios-verbs.sh have
21+
# already loaded by the time we dispatch.
722
#
823
# Skipped when:
924
# - $PS1 unset (non-interactive shell)
1025
# - stdin/stdout are not TTYs (cron, sudo, scripted bash -c, ...)
1126
# - $MIOS_MOTD_SHOWN already set (already shown in this session)
12-
# - $TMUX or $STY set (re-printing the dashboard inside every new
13-
# tmux/screen pane is too noisy; first parent shell already saw it)
27+
# - $TMUX or $STY set (re-printing inside every new tmux/screen
28+
# pane is too noisy; first parent shell already saw it)
29+
# - $MIOS_SKIP_MOTD set (operator opt-out)
1430
#
1531
# Compatible with bash, sh, zsh, dash login shells -- avoids any
1632
# bashism so /bin/sh sources it cleanly.
@@ -20,9 +36,60 @@
2036
[ -z "${MIOS_MOTD_SHOWN:-}" ] || return 0
2137
[ -z "${TMUX:-}" ] || return 0
2238
[ -z "${STY:-}" ] || return 0
39+
[ -z "${MIOS_SKIP_MOTD:-}" ] || return 0
2340

24-
if [ -x /usr/libexec/mios/mios-dashboard.sh ]; then
25-
/usr/libexec/mios/mios-dashboard.sh
26-
MIOS_MOTD_SHOWN=1
27-
export MIOS_MOTD_SHOWN
41+
# Resolve startup verb from mios.toml [terminal.startup]. Per-platform
42+
# .linux key wins over the cross-platform .verb key. Layered overlay
43+
# precedence: ~/.config (operator) > /etc/mios (host) > /usr/share/mios
44+
# (vendor). Empty value = silent shell.
45+
_mios_startup_verb() {
46+
local toml verb section_started key val
47+
for toml in \
48+
"${HOME:-/var/home/mios}/.config/mios/mios.toml" \
49+
/etc/mios/mios.toml \
50+
/usr/share/mios/mios.toml; do
51+
[ -r "$toml" ] || continue
52+
# awk: print value of [terminal.startup].linux first, fall back
53+
# to .verb. Prefer per-platform key.
54+
verb="$(awk '
55+
BEGIN { in_section=0; linux_val=""; verb_val="" }
56+
/^\[/ {
57+
line=$0; sub(/[[:space:]]*#.*$/, "", line)
58+
in_section = (line == "[terminal.startup]") ? 1 : 0
59+
next
60+
}
61+
in_section && /^[[:space:]]*[A-Za-z_][A-Za-z0-9_]*[[:space:]]*=/ {
62+
line=$0; sub(/[[:space:]]*#.*$/, "", line)
63+
eq=index(line, "="); if (eq==0) next
64+
key=substr(line, 1, eq-1); val=substr(line, eq+1)
65+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", key)
66+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", val)
67+
gsub(/^"|"$/, "", val)
68+
if (key == "linux") linux_val = val
69+
if (key == "verb") verb_val = val
70+
}
71+
END { if (linux_val != "") print linux_val; else print verb_val }
72+
' "$toml" 2>/dev/null)"
73+
if [ -n "$verb" ]; then
74+
printf '%s' "$verb"
75+
return 0
76+
fi
77+
done
78+
# Vendor fallback: mini (the compact framed dashboard).
79+
printf 'mini'
80+
}
81+
82+
_mios_verb="$(_mios_startup_verb)"
83+
if [ -n "$_mios_verb" ]; then
84+
# The mios() function is defined by /etc/profile.d/mios-verbs.sh
85+
# (loaded earlier in this profile.d sequence because of `zz-`).
86+
# Type-check it as a function before invoking, in case verb-loading
87+
# was suppressed (e.g., $PS1 unset for some odd login flow).
88+
if type mios 2>/dev/null | head -1 | grep -q 'function'; then
89+
mios "$_mios_verb"
90+
fi
2891
fi
92+
93+
MIOS_MOTD_SHOWN=1
94+
export MIOS_MOTD_SHOWN
95+
unset _mios_verb

0 commit comments

Comments
 (0)