desktop

package
v2.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package desktop gives a target a private graphical display the operator can watch from a browser.

A tool that drives a real browser — a recorded replay, a test in headed mode, an agent clicking through a page — has nowhere to draw on a headless server, and what it would draw is exactly what the operator wants to see. This starts a virtual display with a VNC server and a noVNC web client on the target, all bound to the target's loopback. The control plane reaches the web client with a port forward, so nothing new listens on the target's network.

A browser running inside that display sees the target's own localhost, which is also the simplest way to use a web app that only listens there.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoA11y = fmt.Errorf("this desktop has no accessibility bus (install at-spi2-core, dbus and x11-utils " +
	"on its machine, then start a new desktop); coordinates still work")

ErrNoA11y means the desktop has no accessibility bus to read.

Functions

func A11yAct added in v2.6.0

func A11yAct(ctx context.Context, run Runner, d *Desktop, ref int, action, text string) (string, error)

A11yAct clicks, focuses or types into the element ref names. It uses the element's own accessible action where it has one, and otherwise clicks the middle of its rectangle; via says which happened.

func A11ySnapshot added in v2.6.0

func A11ySnapshot(ctx context.Context, run Runner, d *Desktop) (string, int, error)

A11ySnapshot reads the desktop's accessibility tree: every app, window and control, each actionable one with a [ref=N] and its screen rectangle.

func Act added in v2.6.0

func Act(ctx context.Context, run Runner, d *Desktop, a Action) error

Act performs one action with xdotool.

func KeepAlive added in v2.6.0

func KeepAlive(ctx context.Context, run Runner, dirs ...string) error

KeepAlive tells other servers on the machine these desktops are still in use; Start reaps one whose owner stopped doing this.

func OpenBrowser

func OpenBrowser(ctx context.Context, run Runner, d *Desktop, address string) (string, error)

OpenBrowser starts a browser inside the desktop at address and names the one it found. A target with no browser still has a working desktop: a tool that brings its own, as Playwright does, only needs DISPLAY.

func Screenshot added in v2.6.0

func Screenshot(ctx context.Context, run Runner, d *Desktop) ([]byte, error)

Screenshot captures the whole display as PNG, with whichever capture tool the machine has.

func Stop

func Stop(ctx context.Context, run Runner, dir string) error

Stop ends a desktop and everything started inside it, and removes its state.

Types

type Action added in v2.6.0

type Action struct {
	Type   string `json:"action"` // click|double_click|right_click|move|type|key|scroll
	X      int    `json:"x"`
	Y      int    `json:"y"`
	Text   string `json:"text"`
	Key    string `json:"key"`
	Scroll string `json:"direction"` // up|down|left|right
	Amount int    `json:"amount"`
}

Action is one input to a desktop.

type Desktop

type Desktop struct {
	Dir     string // private state on the target: pids, logs, the browser profile
	Display int    // the X display number: tools run with DISPLAY=:<Display>
	Port    int    // the noVNC web client, on the target's loopback
	Width   int
	Height  int
}

Desktop is one running display.

func Start

func Start(ctx context.Context, run Runner, owner string, width, height int) (*Desktop, error)

Start brings up a display of the given size. owner identifies this server process, so a later server can tell its own desktops from abandoned ones.

type MissingError

type MissingError struct{ Tools []string }

MissingError names what the target needs installed before it can do this.

func (*MissingError) Error

func (e *MissingError) Error() string

type Runner

type Runner func(ctx context.Context, script string) (string, error)

Runner executes a shell script on one target and returns its stdout.

type Window added in v2.6.0

type Window struct {
	ID     string `json:"id"`
	Name   string `json:"name"`
	X      int    `json:"x"`
	Y      int    `json:"y"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
}

Window is one visible top-level window.

func Windows added in v2.6.0

func Windows(ctx context.Context, run Runner, d *Desktop) ([]Window, error)

Windows lists the desktop's visible windows, so an agent knows what is on screen and where before it clicks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL