No description
Find a file
Daniel Baumann 5e1d449363
Releasing fastforward version 0.2.0-2~ffwd13+u1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2026-06-11 07:11:42 +02:00
debian Releasing fastforward version 0.2.0-2~ffwd13+u1. 2026-06-11 07:11:42 +02:00
go.mod Adding upstream version 0.2.0. 2026-06-11 07:11:05 +02:00
LICENSE Adding upstream version 0.2.0. 2026-06-11 07:11:05 +02:00
README.md Adding upstream version 0.2.0. 2026-06-11 07:11:05 +02:00
x11.go Adding upstream version 0.2.0. 2026-06-11 07:11:05 +02:00
x11_test.go Adding upstream version 0.2.0. 2026-06-11 07:11:05 +02:00

x11

PkgGoDev

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:

  • $DISPLAY parsing (unix / abstract / TCP)
  • .Xauthority parsing and MIT-MAGIC-COOKIE-1 selection
  • 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