Files
unkernel/web/index.html
Pooya Parsa b033dc7b50 web: add desktop themes: KDE Plasma, GNOME, iOS, Android and Windows 2000
A theme is a stylesheet under :root[data-desktop] and React parts in place of the top bar, the Dock, the launcher and a window's title bar (web/src/themes); it loads when first shown and switches without a reload. Without a choice the device picks it: iOS, Android, else KDE.

Also: the desktop's headless core (window manager, commands, apps, pins) moves to web/src/core with its tests; terminal tabs are drawn by the theme's title bar; Settings and System get a sidebar drawer in narrow windows; the first paint is a minimal splash; the console's auto-hide is removed.
2026-12-02 20:27:00 +00:00

232 lines
15 KiB
HTML

<!doctype html>
<!-- SPDX-License-Identifier: MIT -->
<!-- Copyright (C) 2026 Pooya Parsa <pooya@pi0.io> -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content">
<meta name="theme-color" content="#000000">
<!-- Added to the home screen, iOS opens the page without Safari's bars (it has no element full screen on iPhone). -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<!-- Not black-translucent: iOS 26+ then gives the page a viewport short of the screen by the status bar and leaves a black band at the bottom (WebKit bug 301108). An opaque bar in the theme's colour instead: black, or default (white) in the light theme (the script below and src/ui.ts showTheme()). -->
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-title" content="unkernel">
<meta name="color-scheme" content="dark">
<title>unkernel</title>
<meta name="description" content="A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="unkernel">
<meta property="og:title" content="unkernel: real Linux, in your browser">
<meta property="og:description" content="A real Linux kernel, compiled to WebAssembly. It boots to a shell in less than a second.">
<meta property="og:url" content="https://unkernel.dev/">
<meta property="og:image" content="https://unkernel.dev/og.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="unkernel: real Linux in your browser. ARM64, Debian or Alpine, up to 16 CPUs, and your tools.">
<meta name="twitter:card" content="summary_large_image">
<!-- For agents: this site's llms.txt (public/llms.txt), which points to the docs. -->
<link rel="alternate" type="text/markdown" href="/llms.txt" title="llms.txt">
<link rel="stylesheet" href="/src/style.css">
<style>
/* The first paint is a splash (the markup in #root below, which React
replaces with the desktop once src/main.tsx runs): a small ring on the
page's plain background, the same under every desktop theme (the theme's
stylesheet comes with the page module). Here, so that it works without
src/style.css too (its theme tokens, with their values as fallbacks):
- the splash (#app[data-static], which React's #app has not; #tb-boot.kw-splash:
the ring turns; on data-error it stops, red, over the failure's title);
- the wallpaper hint (desktop.ts HINT_KEY, applied by the script below)
behind it, and then until desktop.ts has drawn the wallpaper
(data-wallpaper-kind);
- the failure card (#boot-error, outside the inert splash) for a failure
before the page module runs;
and what React's desktop needs from its first render:
- the console's placeholder while it has nothing to show (#app's
data-blank: before the first line, during a quiet resume);
- the boot indicator (#tb-boot, components/BootIndicator.tsx) in the top
bar's app slot: a ring filled to --p (0 to 1) and the step; red with the
failure's title on data-error; it fades out once user space prints. */
#app[data-static] { position: fixed; inset: 0; display: grid; place-items: center; background: var(--color-bg, #000); }
:root[data-theme="light"] #app[data-static] { background: var(--color-bg, #fff); }
.kw-splash { display: grid; justify-items: center; gap: 12px; color: color-mix(in srgb, var(--color-fg, #ededed) 55%, transparent); font: 13px/1.4 var(--font-sans, system-ui, sans-serif); }
:root[data-theme="light"] .kw-splash { color: color-mix(in srgb, var(--color-fg, #171717) 55%, transparent); }
:root[data-wp-hint] .kw-splash { color: rgb(255 255 255 / 80%); }
:root[data-wp-hint][data-wallpaper="light"] .kw-splash { color: rgb(0 0 0 / 60%); }
.kw-splash-ring { animation: kw-splash-turn .9s linear infinite; }
.kw-splash-track { stroke: currentColor; opacity: .25; }
.kw-splash-arc { stroke: currentColor; stroke-dasharray: 28px 100px; }
@keyframes kw-splash-turn { to { transform: rotate(360deg); } }
.kw-splash-msg { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.kw-splash[data-error] .kw-splash-ring { animation: none; }
.kw-splash[data-error] .kw-splash-arc { stroke-dasharray: none; }
:root[data-wp-hint]:not([data-wallpaper-kind]) #app { background: var(--wp-hint); }
:root[data-wp-hint]:not([data-wallpaper-kind]) #desktop { background: none; }
#app[data-blank] #win-terminal-1 > .wm-body::after {
position: absolute; top: 6px; left: 10px; z-index: 1; pointer-events: none;
font: 13px/1.4 var(--font-mono, ui-monospace, monospace); color: var(--color-faint, #7d7d7d); opacity: .7;
}
@media (max-width: 599.98px) { #app[data-blank] #win-terminal-1 > .wm-body::after { top: 4px; left: 8px; font-size: 12px; } }
#app[data-blank="start"] #win-terminal-1 > .wm-body::after { content: "Starting…"; }
#app[data-blank="resume"] #win-terminal-1 > .wm-body::after { content: "Resuming…"; }
.tb-boot { display: flex; flex: 0 1 auto; min-width: 0; height: 100%; align-items: center; transition: opacity .18s ease-out; }
.tb-boot[data-hide] { opacity: 0; pointer-events: none; }
.tb-boot-btn { flex: 0 1 auto; min-width: 0; justify-content: flex-start; gap: 7px; padding: 0 8px; }
.tb-boot-ring { flex: none; }
.tb-boot-track { stroke: color-mix(in srgb, var(--color-ink, #fff) 26%, transparent); }
.tb-boot-arc {
stroke: currentColor; stroke-dasharray: 100px; stroke-dashoffset: calc((1 - var(--p, 0)) * 100px);
transition: stroke-dashoffset .25s ease-out;
/* Breathes once the boot has taken a second: a fast one never shows it moving. */
animation: tb-boot-breathe 1.4s ease-in-out 1s infinite alternate;
}
@keyframes tb-boot-breathe { to { opacity: .45; } }
.tb-boot-msg, .tb-boot-title { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tb-boot-msg { color: color-mix(in srgb, var(--color-fg, #ededed) 72%, transparent); }
.tb-boot-detail { color: color-mix(in srgb, var(--color-fg, #ededed) 45%, transparent); font-variant-numeric: tabular-nums; }
.tb-boot-title { font-weight: 600; }
#tb-boot[data-error] { color: var(--color-err, #ff6166); }
#tb-boot[data-error] .tb-boot-arc { stroke-dashoffset: 0; animation: none; }
@media (max-width: 639.98px) { .tb-boot-detail { display: none; } }
#boot-error {
position: fixed; inset: 0; z-index: var(--z-boot-error, 30); display: grid; place-items: center; padding: 16px;
font: 13px/1.4 var(--font-sans, system-ui, sans-serif); color: var(--color-fg, #ededed);
}
#boot-error > section { background: var(--alert-bg, #111); border: 1px solid var(--alert-border, #333); border-radius: 16px; padding: 20px; text-align: center; }
#boot-error[hidden] { display: none; }
#boot-error .alert-detail { max-height: 10rem; white-space: pre-wrap; }
@media (prefers-reduced-motion: reduce) {
.tb-boot, .tb-boot-arc { transition: none; animation: none; }
.kw-splash-ring { animation: none; }
}
</style>
<script>
// Runs before the page module, so a module that fails to load or throw
// still ends up on screen: on the splash below (the markup React
// replaces once src/main.tsx runs) the ring turns red and the
// failure card shows the message; src/ui.ts shows everything recorded here
// once it runs. Also what the first paint needs from storage: the colour
// themes, the saved wallpaper's hint (desktop.ts HINT_KEY) and compact mode for a mobile
// user agent without a touch screen (config.ts mobile).
(() => {
const KW = window.KW = { t0: Date.now(), errors: [], ui: null, started: false };
const root = document.documentElement;
try {
const p = localStorage.getItem("kw.theme");
const theme = p === "light" || (p !== "dark" && matchMedia("(prefers-color-scheme: light)").matches) ? "light" : "dark";
root.setAttribute("data-theme", theme);
document.querySelector('meta[name="theme-color"]').setAttribute("content", theme === "light" ? "#ffffff" : "#000000");
document.querySelector('meta[name="color-scheme"]').setAttribute("content", theme);
document.querySelector('meta[name="apple-mobile-web-app-status-bar-style"]').setAttribute("content", theme === "light" ? "default" : "black");
// The desktop theme (src/themes/index.ts): ?desktop=, else the preference, else its DEFAULT_THEME.
const ua = navigator.userAgent;
const d = new URLSearchParams(location.search).get("desktop") || localStorage.getItem("kw.desktop-theme")
|| (/iPhone|iPad|iPod/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1) ? "ios" : /Android/.test(ua) ? "android" : "kde");
if (/^[a-z0-9-]+$/.test(d)) root.setAttribute("data-desktop", d);
const t = localStorage.getItem("kw.termtheme");
root.setAttribute("data-term-theme", t === "light" || t === "dark" ? t : theme);
root.setAttribute("data-term-glass", localStorage.getItem("kw.termglass") === "off" ? "off" : "on");
const h = JSON.parse(localStorage.getItem("kw.wallpaper-hint") || "null");
if (h && typeof h.css === "string") {
root.style.setProperty("--wp-hint", h.css);
root.setAttribute("data-wp-hint", "");
root.setAttribute("data-wallpaper", h.light ? "light" : "dark");
}
} catch {}
if (/Android|iPhone|iPad|Mobi/i.test(navigator.userAgent)) root.classList.add("kw-mobile");
const el = (id) => document.getElementById(id);
// Before src/ui.ts takes over: the ring and the card on the splash.
KW.early = (e) => {
if (!e.fatal || !el("tb-boot")) return;
el("tb-boot").setAttribute("data-error", "");
const title = el("tb-boot-title"), msg = el("tb-boot-msg"), card = el("boot-error");
if (title) { title.textContent = "Couldn't start"; title.hidden = false; }
if (msg) msg.textContent = e.message;
if (card) {
el("boot-error-msg").textContent = e.message;
el("boot-error-detail").textContent = e.detail || "";
el("boot-error-detail").hidden = !e.detail;
card.hidden = false;
}
};
KW.report = (kind, message, detail, fatal) => {
const e = { t: Date.now() - KW.t0, kind, message: String(message), detail: detail ? String(detail) : "", fatal: !!fatal };
KW.errors.push(e);
try { if (KW.ui) KW.ui.onError(e); else KW.early(e); } catch { KW.early(e); }
return e;
};
addEventListener("error", (ev) => {
const t = ev.target;
if (t && t !== window && t.tagName) {
const url = t.src || t.href || "";
// A failed script is fatal; a failed stylesheet only degrades the look.
KW.report("resource", "Failed to load " + (t.type === "module" ? "the page module " + url + " or a module it imports" : url),
"<" + t.tagName.toLowerCase() + "> load error (404, network or MIME type)", t.tagName === "SCRIPT");
return;
}
// Not a failure: a ResizeObserver callback changed a size an outer observer watches (a Wayland app's
// new size resizing its window, wayland/host.ts), and the browser delivers that one next frame instead.
if (!ev.error && /^ResizeObserver loop/.test(ev.message || "")) return;
// Scripts a browser or an extension injects (Brave's wallet touching window.ethereum, say) throw here too:
// drop an error that names no script of the page's origin (a blob: URL of it, or wasm), so it cannot fail the boot.
if (location.origin !== "null") {
let ours;
try {
const u = new URL(ev.filename);
ours = u.origin === location.origin || u.protocol === "wasm:";
} catch {
ours = String(ev.error?.stack || "").includes(location.origin);
}
if (!ours) return;
}
KW.report("exception", ev.message || "Script error", ev.error?.stack || (ev.filename ? ev.filename + ":" + ev.lineno + ":" + ev.colno : ""), !KW.started);
}, true);
addEventListener("unhandledrejection", (ev) => {
const r = ev.reason;
KW.report("rejection", "Unhandled promise rejection: " + (r?.message ?? String(r)), r?.stack ?? "", !KW.started);
});
setTimeout(() => {
if (!KW.ui) KW.report("watchdog", "The page script did not run",
"The page module failed to load or parse, or the browser is too old for it (Chrome/Edge 137+, Firefox 153+ or Safari 27+ is needed anyway). Check the network and the server log.", true);
}, 8000);
})();
</script>
<link rel="icon" type="image/svg+xml" href="../assets/logo.svg">
<!-- The home screen icon (iOS takes no SVG here): assets/logo.svg full bleed, inside its border, at 6x. -->
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<!-- Installable as an app (public/manifest.webmanifest). -->
<link rel="manifest" href="/manifest.webmanifest">
</head>
<body>
<!-- React (src/main.tsx) renders the page here. Until then, and if the page
module never runs, this is what shows: a splash (inert), a small ring on
the page's background, the same under every desktop theme; the failure
card is for a failure before then. -->
<div id="root">
<div id="app" data-static data-state="checking" inert>
<div id="tb-boot" role="status" aria-live="polite" class="kw-splash">
<svg class="kw-splash-ring" width="22" height="22" viewBox="0 0 16 16" fill="none" aria-hidden="true"><circle cx="8" cy="8" r="6" stroke-width="1.75" class="kw-splash-track" /><circle cx="8" cy="8" r="6" stroke-width="1.75" pathLength="100" stroke-linecap="round" class="kw-splash-arc" /></svg>
<span id="tb-boot-title" hidden></span>
<span id="tb-boot-msg" class="kw-splash-msg">Starting</span>
</div>
</div>
<div id="boot-error" hidden>
<section role="alert" aria-labelledby="boot-error-title" class="alert alert-wide">
<div aria-hidden="true" class="relative mx-auto" style="width: 48px; height: 48px"><svg width="48" height="48" viewBox="0 0 32 32"><rect x="0.5" y="0.5" width="31" height="31" rx="7.5" fill="#000" stroke="#333" /><path d="M9 11l5.5 5L9 21" stroke="#ededed" stroke-width="2.4" fill="none" stroke-linecap="round" stroke-linejoin="round" /><path d="M16.5 21.5H23" stroke="#ededed" stroke-width="2.4" stroke-linecap="round" /></svg><svg width="24" height="24" viewBox="0 0 24 24" class="absolute -right-1.5 -bottom-1.5" style="position: absolute; right: -6px; bottom: -6px"><circle cx="12" cy="12" r="10.2" fill="#e5484d" stroke="#111" stroke-width="1.6" /><path d="M12 6.8v6.4" stroke="#fff" stroke-width="2.2" stroke-linecap="round" /><circle cx="12" cy="16.9" r="1.3" fill="#fff" /></svg></div>
<h2 id="boot-error-title" class="alert-title">Couldn't start</h2>
<p id="boot-error-msg" class="alert-msg"></p>
<p id="boot-error-detail" class="alert-detail" hidden></p>
<div class="alert-actions"><button type="button" class="btn btn-alert btn-primary" onclick="location.reload()">Reload</button></div>
</section>
</div>
</div>
<noscript><div class="fixed inset-0 z-50 grid place-items-center bg-bg p-6 text-center"><div class="max-w-[420px]"><h1 class="mb-1.5 text-lg font-semibold">JavaScript is required</h1><p class="text-[13.5px] text-muted">This page boots a Linux kernel compiled to WebAssembly, which needs JavaScript. Enable it for this site and reload.</p></div></div></noscript>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>