Watch
1
0
Fork
You've already forked golang-golang-x-x11
0
No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Daniel Baumann 55490b5a8a
Releasing debian version 0.2.0-3.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2026-08-31 15:32:59 +02:00
debian Releasing debian version 0.2.0-3. 2026-08-31 15:32:59 +02:00
go.mod Adding upstream version 0.2.0. 2026-06-09 18:54:54 +02:00
LICENSE Adding upstream version 0.2.0. 2026-06-09 18:54:54 +02:00
README.md Adding upstream version 0.2.0. 2026-06-09 18:54:54 +02:00
x11.go Adding upstream version 0.2.0. 2026-06-09 18:54:54 +02:00
x11_test.go Adding upstream version 0.2.0. 2026-06-09 18:54:54 +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