aboutsummaryrefslogtreecommitdiffstats
path: root/web/demo/overlay
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-19 20:11:10 +0200
committeruser <user@clank>2026-08-19 20:11:10 +0200
commit76f3868cd7b775cb59b85a32c2b223732f6afc30 (patch)
treee38858cabf624732ca48ae7a8b4c49e9af65728c /web/demo/overlay
parentslosh: layout files are *.layout, not *.layout.kdl (diff)
downloadslosh-76f3868cd7b775cb59b85a32c2b223732f6afc30.tar.gz
slosh-76f3868cd7b775cb59b85a32c2b223732f6afc30.tar.xz
slosh-76f3868cd7b775cb59b85a32c2b223732f6afc30.zip
slosh: the website lives in web/ -- one directory, one build, make www
Consolidate everything the website is made of: - web_new/ -> web/: the front page, install.sh, and build-site - contrib/webdemo/ -> web/demo/: the in-browser machine, committed for the first time (it had never been checked in) - make www at the top level assembles the whole site into build/www (NO_DEMO=1 skips the guest cross-compile) - web_plan.md deleted: the plan is fulfilled and web/README.md is now the record Path fallout: the overlay theme symlink gains one ../ (web/demo is a level shallower relative to contrib/themes), PYSRC in the Makefile follows the demo scripts, contrib/README.md drops its webdemo section. ROOT := ../.. in the demo Makefile survives unchanged -- web/demo sits at the same depth contrib/webdemo did. Verified: make www builds front page + docs + demo end to end, web/demo make check boots the image to slosh, tests/test_docs.py and make fmt-check green.
Diffstat (limited to 'web/demo/overlay')
-rwxr-xr-xweb/demo/overlay/etc/init.d/rcS44
-rw-r--r--web/demo/overlay/etc/inittab25
-rw-r--r--web/demo/overlay/etc/motd5
-rw-r--r--web/demo/overlay/etc/profile24
-rw-r--r--web/demo/overlay/root/.config/slosh/config.kdl29
l---------web/demo/overlay/root/.config/slosh/themes/sl0p.kdl1
-rw-r--r--web/demo/overlay/root/.vimrc23
-rw-r--r--web/demo/overlay/root/demo.layout27
8 files changed, 178 insertions, 0 deletions
diff --git a/web/demo/overlay/etc/init.d/rcS b/web/demo/overlay/etc/init.d/rcS
new file mode 100755
index 0000000..48bf717
--- /dev/null
+++ b/web/demo/overlay/etc/init.d/rcS
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Everything this machine needs before the session starts, and nothing else.
+#
+# Quiet on purpose: this writes to the console the visitor is about to watch
+# slosh draw on, and a wall of boot chatter under a terminal multiplexer
+# reads as something having gone wrong.
+#
+# Deliberately not `set -e`: a mount that is already there must not stop the
+# ones after it, and one of those is devpts -- without which the demo has no
+# panes at all.
+
+mountpoint -q /proc || mount -t proc proc /proc
+mountpoint -q /sys || mount -t sysfs sysfs /sys
+
+# The guest kernel is built with CONFIG_DEVTMPFS_MOUNT, so /dev is already
+# populated by the time init runs. Kept as a guard rather than dropped: it is
+# one line, and it is what makes the rest of this script true on a kernel
+# without that option.
+mountpoint -q /dev || mount -t devtmpfs devtmpfs /dev
+
+# Load-bearing, and the first thing to look at if the demo comes up with no
+# panes in it: slosh gives every pane a pty of its own through
+# posix_openpt(3), which is devpts or nothing. gid 5 is `tty` in Alpine's
+# /etc/group, and ptmxmode is what makes /dev/ptmx openable at all.
+mkdir -p /dev/pts
+mountpoint -q /dev/pts ||
+ mount -t devpts -o ptmxmode=0666,gid=5,mode=620 devpts /dev/pts
+[ -e /dev/ptmx ] || ln -s pts/ptmx /dev/ptmx
+
+# Somewhere to write. The session's control socket lands under /tmp
+# (/tmp/slosh-0/<name>.sock, since $XDG_RUNTIME_DIR is unset here), so a
+# read-only /tmp is a session that cannot start. /dev/shm is not used by
+# anything we ship, but musl's shm_open expects it and the cost is nothing.
+mountpoint -q /tmp || mount -t tmpfs -o size=16m,mode=1777 tmpfs /tmp
+mountpoint -q /run || mount -t tmpfs -o size=4m,mode=0755 tmpfs /run
+mkdir -p /dev/shm
+mountpoint -q /dev/shm || mount -t tmpfs -o size=8m,mode=1777 tmpfs /dev/shm
+
+hostname slosh-demo
+
+# The console is a terminal a full-screen program is about to own, and a kernel
+# message arriving mid-session would be painted straight over it. Only panics
+# get through from here on.
+dmesg -n 1 2>/dev/null
diff --git a/web/demo/overlay/etc/inittab b/web/demo/overlay/etc/inittab
new file mode 100644
index 0000000..6523b0d
--- /dev/null
+++ b/web/demo/overlay/etc/inittab
@@ -0,0 +1,25 @@
+# busybox init, on a machine whose entire job is to hold one slosh session.
+#
+# This replaces Alpine's own inittab, which hands everything to openrc -- a
+# service manager that is not in the minirootfs and that this machine has no
+# services for. Four lines is the whole boot.
+#
+# Fields are <tty>:<runlevels>:<action>:<command>. The tty field is empty so
+# every entry inherits init's console, which is the one the kernel was told
+# about on the command line (console=hvc0) rather than a device this file has
+# to name.
+::sysinit:/etc/init.d/rcS
+
+# The visitor lands *in* slosh. There is nothing else on this machine to do,
+# and a shell prompt in front of a demo of a terminal multiplexer is a wasted
+# screen. `respawn` because quitting the session -- C-a q, or closing the last
+# pane -- has to bring it straight back: an empty console reads as a crash.
+#
+# It goes through a shell for two reasons: /etc/profile is the environment
+# every pane will inherit, and busybox init would otherwise split this line on
+# spaces itself and exec it directly.
+::respawn:/bin/sh -c '. /etc/profile; exec /usr/bin/slosh --layout /root/demo.layout'
+
+# There is no reset button on a browser tab.
+::ctrlaltdel:/sbin/reboot
+::shutdown:/bin/umount -a -r
diff --git a/web/demo/overlay/etc/motd b/web/demo/overlay/etc/motd
new file mode 100644
index 0000000..c676471
--- /dev/null
+++ b/web/demo/overlay/etc/motd
@@ -0,0 +1,5 @@
+slosh: panes, tabs and sessions, on riscv64 Linux inside your browser.
+The machine is yours and it is throwaway -- reload the page and it is gone.
+The leader is C-a: C-a Enter splits, C-a z zooms, C-a ? lists every key.
+These three panes are a file, /root/demo.layout, and so is the theme.
+The real thing, and the source of all of this, is linked beside the terminal.
diff --git a/web/demo/overlay/etc/profile b/web/demo/overlay/etc/profile
new file mode 100644
index 0000000..057730e
--- /dev/null
+++ b/web/demo/overlay/etc/profile
@@ -0,0 +1,24 @@
+# The environment every pane inherits.
+#
+# Sourced by the line in /etc/inittab that starts the session, so slosh gets
+# it and hands it on. A pane's shell is not a login shell and reads nothing at
+# startup, which is why PS1 is exported here rather than left in a file no pane
+# will ever open.
+#
+# TERM is what *slosh itself* is looking at -- xterm.js in the browser. It is
+# not what a program in a pane is told: slosh sets TERM=xterm-ghostty on the
+# far side of every pty it opens (src/pty.c:67), because that is the terminal
+# it implements. That name resolves: build-rootfs aliases xterm-ghostty to
+# xterm-256color in the image's terminfo, which is the subset both speak.
+#
+# COLORTERM because it is true -- the VT does 24-bit colour -- and because it
+# is what lets vim pick truecolor over the 256 the terminfo alias admits to.
+TERM=xterm-256color
+COLORTERM=truecolor
+HOME=/root
+PATH=/usr/bin:/usr/sbin:/bin:/sbin
+PS1='slosh-demo:\w \$ '
+export TERM COLORTERM HOME PATH PS1
+
+# The motd belongs in a pane, not on the console underneath the session: the
+# layout gives it a pane of its own, where it can be read.
diff --git a/web/demo/overlay/root/.config/slosh/config.kdl b/web/demo/overlay/root/.config/slosh/config.kdl
new file mode 100644
index 0000000..3252da7
--- /dev/null
+++ b/web/demo/overlay/root/.config/slosh/config.kdl
@@ -0,0 +1,29 @@
+// The demo's config. Deliberately about twenty lines: the reference config with
+// every setting and the reasoning attached is config/config.kdl in the source
+// tree, and 48KB of commentary is the wrong thing to ship to a browser.
+//
+// Saving a config applies to a running session, so this file is also a thing to
+// edit from inside the demo: `C-a e` opens it in a pane.
+
+// The default palette, from the file the repo ships rather than a second copy
+// of it -- overlay/root/.config/slosh/themes/sl0p.kdl is a symlink to
+// contrib/themes/sl0p.kdl, so this is the same sl0p as everywhere else and it
+// cannot fall behind. An include is resolved against *this* file's directory.
+include "themes/sl0p.kdl"
+
+// Busybox ash is the only shell on this machine and $SHELL is not set on it.
+shell "/bin/sh"
+
+// A tenth of the default history. The whole machine is 32MB of disk and
+// whatever RAM the page asked for, and nothing here will produce 1000 lines.
+scrollback 1000
+
+// Enough gap to see the frames, without spending a column this terminal does
+// not have. `gap` is in rows and comes out square (gap_aspect).
+gap 1
+padding 0 1
+
+// No shader by default: a cursor-line wash reads as a rendering artifact to
+// anyone who did not ask for it. The shader system is one paste away --
+// contrib/shaders/ has thirty-two of them, and `C-a e` opens this file in a
+// pane; it is re-read the moment you save.
diff --git a/web/demo/overlay/root/.config/slosh/themes/sl0p.kdl b/web/demo/overlay/root/.config/slosh/themes/sl0p.kdl
new file mode 120000
index 0000000..9306464
--- /dev/null
+++ b/web/demo/overlay/root/.config/slosh/themes/sl0p.kdl
@@ -0,0 +1 @@
+../../../../../../../contrib/themes/sl0p.kdl \ No newline at end of file
diff --git a/web/demo/overlay/root/.vimrc b/web/demo/overlay/root/.vimrc
new file mode 100644
index 0000000..6974506
--- /dev/null
+++ b/web/demo/overlay/root/.vimrc
@@ -0,0 +1,23 @@
+" The demo's vim: syntax highlighting on a pruned runtime -- syntax/,
+" filetype detection, colours, and nothing else. :help is not installed.
+set nocompatible
+filetype on
+syntax on
+
+" slosh's terminal does 24-bit colour (it is most of what the shaders are),
+" and the pane's TERM is an alias of xterm-256color, whose terminfo does not
+" say so. COLORTERM comes from /etc/profile; the t_8f/t_8b overrides are the
+" standard incantation for truecolor on a TERM that is not *-direct.
+if $COLORTERM ==# 'truecolor'
+ let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
+ let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
+ set termguicolors
+endif
+colorscheme habamax
+
+" A pane in an emulated machine: keep vim from wanting things that are not
+" there. No swapfile chatter on a throwaway disk, no mouse fights with the
+" multiplexer's own mouse handling.
+set noswapfile
+set mouse=
+set laststatus=1
diff --git a/web/demo/overlay/root/demo.layout b/web/demo/overlay/root/demo.layout
new file mode 100644
index 0000000..a5b6bd2
--- /dev/null
+++ b/web/demo/overlay/root/demo.layout
@@ -0,0 +1,27 @@
+// What the visitor lands in: one tab, three panes, one screen.
+//
+// slosh --layout /root/demo.layout
+//
+// which is the line /etc/inittab respawns. No `cwd=` anywhere in it: a relative
+// path in a layout file means the directory the file is in, and a pane with no
+// cwd at all starts there too -- so every pane here starts in /root.
+layout {
+ tab name="demo" purpose="demo" {
+
+ // The greeting, and a shell under it. This pane was *given* a command,
+ // so typing `exit` leaves the corpse and an offer to re-run it (`C-a r`)
+ // rather than closing the pane -- which is a pane state worth seeing.
+ pane focus=true purpose="demo:welcome" command="cat /etc/motd; exec /bin/sh"
+
+ pane split="rows" {
+
+ // Laid out, running nothing, started by your first keystroke: the
+ // pane shows what it *would* run. Here it is also the proof that
+ // the machine underneath is a real riscv64 one.
+ pane purpose="demo:machine" command="cat /proc/cpuinfo" suspended=true
+
+ // No command: the session's shell, in /root.
+ pane purpose="demo:shell"
+ }
+ }
+}