No description
- Go 100%
|
|
||
|---|---|---|
| debian | ||
| go.mod | ||
| LICENSE | ||
| README.md | ||
| x11.go | ||
| x11_test.go | ||
x11
A minimal, pure-Go client for the X11 wire protocol — no Cgo, no libX11.
import "golang.design/x/x11"
Package x11 implements the encoding, decoding, and parsing for the slice of
the X Window System Protocol, version 11
needed to talk to an X server directly over its socket:
$DISPLAYparsing (unix / abstract / TCP).Xauthorityparsing andMIT-MAGIC-COOKIE-1selection- connection setup request + setup-reply parsing, resource-ID allocation
- requests:
InternAtom,CreateWindow,Set/GetSelectionOwner,ConvertSelection,ChangeProperty,GetProperty,DeleteProperty,SendEvent,GetInputFocus - packet reading and reply/event/error decoding
It contains only the wire logic — no sockets. Callers own the transport
(net.Conn, an io.Reader, …), which keeps the package free of OS-specific
code and unit-testable on any platform.
This package was extracted from golang.design/x/clipboard,
where it backs the Cgo-free X11 clipboard on Linux and the BSDs.
Example
Sketch of reading the connection setup over a dialed socket:
conn, _ := net.Dial("unix", "/tmp/.X11-unix/X0")
conn.Write(x11.SetupRequest("", nil)) // or a MIT-MAGIC-COOKIE-1 from .Xauthority
setup, err := x11.ReadSetup(bufio.NewReader(conn))
if err != nil {
// ...
}
ids := x11.NewIDGen(setup)
win := ids.Next()
conn.Write(x11.CreateWindow(win, setup.Root))
See golang.design/x/clipboard's
X11 backend for a complete, working consumer.
License
MIT © The golang.design Initiative Authors