X gets a VT: keyboard, terminal switching, and a way out

Xorg uses VTs only when stat("/dev/tty0") reports Linux's tty major 4.
SchOS's terminals sit under major 1, so X ran on no VT at all: the console
kept drawing over it, Ctrl+Alt+F-keys did nothing, and nothing ended the
session. stat now reports terminals under Linux's numbers.

startx picks the VT only when uname says Linux, so root's xserverrc passes
the current one itself. An xorg.conf.d file names X's input devices, since
Alpine's Xorg looks them up through udev and SchOS has none yet.

Alt+F1..F6 and Ctrl+Alt+F1..F6 now switch terminals as on Linux, alongside
the settable chord. USB keyboards gain arrows, Home/End/PgUp/PgDn/Ins/Del
and the switch keys, which the PS/2 path always had.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
Nexoniarz 2026-10-24 21:45:50 +02:00
commit 4a7165c951
5 changed files with 123 additions and 9 deletions

View file

@ -106,7 +106,10 @@ rm -f "$P/etc/profile"
mkdir -p "$P/root"
cat > "$P/root/.xserverrc" <<'XEOF'
#!/bin/sh
exec /usr/bin/X -nolisten tcp -dumbSched "$@"
# The VT X runs on is the one startx was started from. startx works that out
# only when `uname -s` says Linux, and SchOS's says SchIFT.
vt=$(tty | sed -n 's|^/dev/tty\([0-9][0-9]*\)$|vt\1|p')
exec /usr/bin/X -nolisten tcp -dumbSched $vt "$@"
XEOF
# What startx runs inside it: Window Maker, which world installs. Without this
@ -116,6 +119,55 @@ cat > "$P/root/.xinitrc" <<'XEOF'
exec wmaker
XEOF
# X's input devices, named rather than found. Alpine's Xorg asks udev for
# them, SchOS has no udev, and X came up with no keyboard and no mouse: the
# pointer did not move, Ctrl+Alt+F-keys did nothing and nothing could end the
# session. SchOS has exactly two input nodes whatever the machine -- every
# keyboard on event0, every mouse on event1 (kernel/dev/input.c) -- so a
# fixed list is the whole answer. The file is SchOS's, in xorg.conf.d, which
# no Alpine package writes into.
mkdir -p "$P/etc/X11/xorg.conf.d"
cat > "$P/etc/X11/xorg.conf.d/10-schos.conf" <<'XEOF'
# SchOS has no udev, so X is told its input devices instead of finding them.
# event0 is every keyboard and event1 every mouse (kernel/dev/input.c).
Section "ServerFlags"
Option "AutoAddDevices" "false"
# Ctrl+Alt+Backspace ends X.
Option "DontZap" "false"
EndSection
Section "InputDevice"
Identifier "keyboard"
Driver "evdev"
Option "Device" "/dev/input/event0"
Option "XkbRules" "evdev"
Option "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection
Section "InputDevice"
Identifier "mouse"
Driver "evdev"
Option "Device" "/dev/input/event1"
EndSection
Section "Device"
Identifier "fb"
Driver "fbdev"
EndSection
Section "Screen"
Identifier "screen"
Device "fb"
EndSection
Section "ServerLayout"
Identifier "schos"
Screen "screen"
InputDevice "keyboard" "CoreKeyboard"
InputDevice "mouse" "CorePointer"
EndSection
XEOF
# Mount points and runtime directories are alpine-baselayout's; an empty
# directory here only duplicates it.
for d in dev proc sys run tmp srv; do