tty: AltGr+F1..F6 by default, and AltGr+-/+ to step

The sweet spot was available the whole time and I ruled it out by writing
"AltGr+anything" when the true statement is "AltGr+*letter*".

A Polish layout wants AltGr with a letter -- ą ć ę ł ń ó ś ź ż. AltGr with a
function key produces nothing on any layout, no window manager binds it, and
no application asks for it. It is the one combination the host, applications
and the keyboard layout all leave alone, and the previous three commits talked
themselves out of it on a technicality that was mine, not the hardware's.

Verified rather than argued, with QEMU sendkey and screendump hashes:

    AltGr+F2   -> tty2
    AltGr+F1   -> back, pixel-identical to the start
    AltGr+a    -> reaches zsh, so ą still types

That distinction is only expressible because Right Alt became its own modifier
bit two commits ago. Sharing ALT is harmless for typing -- neither is used to
look up a character -- and made this impossible to say.

Also added, since it was asked for in the same breath: minus and equals step
to the previous and next terminal, on whatever the chord's modifiers are. They
skip terminals that are not in use -- the same `opened` count VT_GETSTATE
reports -- because six terminals with two shells on them means four blank
screens in between, and cycling past those is worse than not having the key.

    AltGr+=  -> tty2, again -> wraps to tty1   (only two in use)
    AltGr+-  -> tty2

chvt -c still moves all of it, and `chvt` reports both halves.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
This commit is contained in:
Nexoniarz 2026-09-13 13:22:01 +02:00
commit 65906639da
8 changed files with 118 additions and 31 deletions

View file

@ -1,9 +1,15 @@
<!-- SPDX-License-Identifier: Apache-2.0 -->
# Virtual terminals
Six of them, `/dev/tty1` through `/dev/tty6`, reached with `chvt N` or with
a keyboard chord — **Ctrl+Shift+F1 .. F6** by default, and settable, for
reasons below. Each one is an independent terminal: its own screen, its own
Six of them, `/dev/tty1` through `/dev/tty6`.
| | |
|---|---|
| **AltGr+F1 .. F6** | go to that terminal |
| **AltGr+-** / **AltGr+=** | previous / next terminal *in use* |
| `chvt N` | the same, from a script or a serial console |
The chord is settable — `chvt -c` — for the reasons below. Each one is an independent terminal: its own screen, its own
cursor, its own line discipline, its own foreground process group and its own
session. Two shells on two terminals are two unrelated processes that happen to
share a keyboard and a screen.
@ -133,8 +139,8 @@ So the kernel ships a default and lets it be moved:
```sh
chvt # report the active terminal and the current chord
chvt -c ctrl+shift+F # Ctrl+Shift+F1..F6 (the default)
chvt -c ctrl+alt+shift+F # if your host leaves that alone
chvt -c altgr+F # AltGr+F1..F6 (the default)
chvt -c ctrl+shift+F # Ctrl+Shift+F1..F6
chvt -c alt+1 # Alt+1..6
chvt -c off # no chord; chvt N is then the only way
```
@ -142,9 +148,25 @@ chvt -c off # no chord; chvt N is then the only way
`off` is a legitimate setting, not a failure mode. On a machine whose host
grabs everything worth binding, `chvt N` from a shell is the honest answer.
The default is `Ctrl+Shift+F1..F6` because display managers bind `Ctrl+Alt+F<n>`
rather than `Ctrl+Shift+F<n>`, and because `Ctrl+Shift` with a *function key*
is not a character on any layout — unlike `Ctrl+Shift+`digit, which is.
The default is **AltGr+F1..F6**, and the `AltGr+`letter row above needs reading
carefully: what a Polish layout wants is AltGr with a **letter**. AltGr with a
**function key** produces nothing on any layout, no window manager binds it,
and no application asks for it. It is the one combination all three parties
leave alone.
That distinction is only expressible because Right Alt is tracked as its own
modifier bit. It used to share `ALT`, which is harmless for typing — neither is
used to look up a character — and made this impossible to say.
Verified rather than argued: with the default set, `AltGr+F2` switches,
`AltGr+F1` returns to a pixel-identical tty1, and `AltGr+a` still reaches the
shell, so ą is untouched.
Whatever the modifiers are, they also bind **minus** and **equals** to the
previous and next terminal. Those step only through terminals that are *in
use* — the same `opened` count `VT_GETSTATE` reports — because six terminals
with two shells on them means four blank screens in between, and cycling past
them is worse than not having the key.
Which chords reach a guest at all was **measured, not assumed**: a temporary
probe in `kbdgetc` logged every modified keypress, and QEMU's `sendkey` fired