Debian Codegraph @

README.md

raw
1 # x11
2
3 [![PkgGoDev](https://pkg.go.dev/badge/golang.design/x/x11)](https://pkg.go.dev/golang.design/x/x11)
4
5 A minimal, **pure-Go** client for the X11 wire protocol — no Cgo, no `libX11`.
6
7 ```
8 import "golang.design/x/x11"
9 ```
10
11 Package `x11` implements the encoding, decoding, and parsing for the slice of
12 the [X Window System Protocol, version 11](https://www.x.org/releases/current/doc/xproto/x11protocol.html)
13 needed to talk to an X server directly over its socket:
14
15 - `$DISPLAY` parsing (unix / abstract / TCP)
16 - `.Xauthority` parsing and `MIT-MAGIC-COOKIE-1` selection
17 - connection setup request + setup-reply parsing, resource-ID allocation
18 - requests: `InternAtom`, `CreateWindow`, `Set`/`GetSelectionOwner`,
19 `ConvertSelection`, `ChangeProperty`, `GetProperty`, `DeleteProperty`,
20 `SendEvent`, `GetInputFocus`
21 - packet reading and reply/event/error decoding
22
23 It contains **only** the wire logic — no sockets. Callers own the transport
24 (`net.Conn`, an `io.Reader`, …), which keeps the package free of OS-specific
25 code and unit-testable on any platform.
26
27 This package was extracted from [`golang.design/x/clipboard`](https://github.com/golang-design/clipboard),
28 where it backs the Cgo-free X11 clipboard on Linux and the BSDs.
29
30 ## Example
31
32 Sketch of reading the connection setup over a dialed socket:
33
34 ```go
35 conn, _ := net.Dial("unix", "/tmp/.X11-unix/X0")
36 conn.Write(x11.SetupRequest("", nil)) // or a MIT-MAGIC-COOKIE-1 from .Xauthority
37 setup, err := x11.ReadSetup(bufio.NewReader(conn))
38 if err != nil {
39 // ...
40 }
41 ids := x11.NewIDGen(setup)
42 win := ids.Next()
43 conn.Write(x11.CreateWindow(win, setup.Root))
44 ```
45
46 See [`golang.design/x/clipboard`](https://github.com/golang-design/clipboard)'s
47 X11 backend for a complete, working consumer.
48
49 ## License
50
51 MIT © The golang.design Initiative Authors