# Linux Wayland and X11 Desktop Control

> Automate native Linux desktop apps on GNOME Wayland (including headless virtual displays) and X11 with Mutter ScreenCast screenshots, Mutter RemoteDesktop input, AT-SPI2 background actions, local Tesseract OCR, and lock-screen safety guards.

Linux Wayland and X11 Desktop Control is a paid AI agent skill on Agensi by NaghtSieger, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $14.99 (one-time purchase)
- Creator: [NaghtSieger](https://www.agensi.io/creators/naghtsieger)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Version: 1.0.0
- Last updated: 2026-12-04
- Security: scan passed (2026-12-04); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/linux-wayland-and-x11-desktop-control
- Tags: ai-agents, automation, devops, linux, wayland, computer-use, desktop-automation, gnome

## What it does

- Detects session lock (SESSION_LOCKED), Wayland/X11 environment, monitor geometry, and backends—even via SSH
- Inspects native Linux UI trees via AT-SPI2 and invokes buttons, edits text, or selects text in background
- Captures window or monitor PNG screenshots on GNOME Wayland via Mutter.ScreenCast + PipeWire, grim, or X11
- Extracts line bounding boxes and pixel click centers from Chrome or Electron via Tesseract OCR (eng/chi_sim)
- Injects Wayland/X11 clicks, smooth scroll, drags, chords, and Unicode/CJK text with clipboard backup/restore

## Who it's for

- **Ubuntu & Fedora Wayland developers:** True GNOME Wayland desktop automation where legacy X11 xdotool scripts fail Try: "Run Linux desktop capabilities preflight, capture the active GNOME window with OCR, and click the Settings button."
- **Headless Linux workstation owners:** Works on virtual gnome-remote-desktop Wayland sessions and automatically discovers WAYLAND_DISPLAY / D-Bus from SSH Try: "List open windows on my headless Ubuntu Wayland session and inspect the target app's AT-SPI2 controls."
- **QA & desktop app engineers:** Fast AT-SPI2 background control combined with local Tesseract OCR fallback for Electron and browser UIs Try: "Inspect the open GTK app with AT-SPI2, fill the search field in the background, and verify the updated list."
- **AI coding agent users on Linux:** Five compact, self-contained Python 3 CLI scripts with zero npm dependencies and strict lock-screen safety Try: "Capture a cropped screenshot of my Linux app, run Tesseract OCR, and scroll down smoothly."

## About this skill

Most Linux computer-use tools assume legacy X11 and break immediately on modern Ubuntu, Fedora, and GNOME Wayland desktops—or fail silently when launched from an SSH session or headless virtual display.

### How it works
This skill equips your AI agent with five compact, standalone Python 3 scripts designed natively for **GNOME Wayland** while preserving full **wlroots Wayland** and **X11** fallback support:
1. **Desktop Auto-Discovery & Lock-Screen Guard**: Automatically resolves `WAYLAND_DISPLAY`, `DISPLAY`, and `DBUS_SESSION_BUS_ADDRESS` (even from non-login or SSH shells) and fails closed with `SESSION_LOCKED` whenever the screen is locked.
2. **AT-SPI2 Background Control**: Reads the live Linux accessibility tree with deterministic node paths so the agent can invoke buttons, write text into editable fields, and select text without stealing the mouse cursor.
3. **Native Wayland ScreenCast + Local Tesseract OCR**: Captures PNG screenshots directly from GNOME `Mutter.ScreenCast` over PipeWire (`pipewiresrc` + `pngenc`), crops cleanly to window bounds with HiDPI awareness, and runs local Tesseract TSV OCR to return exact line bounding boxes and click centers.
4. **Wayland Pointer & Keyboard Injection**: Uses `Mutter.RemoteDesktop` D-Bus (falling back cleanly to `ydotool` or `xdotool`), wraps every modifier and mouse button in `try/finally` release guards, and automatically routes non-ASCII/CJK text through clipboard-preserving `Ctrl+V` paste so XKB never drops Unicode characters.

### Frameworks & tools
Pure Python 3 scripts using native Linux desktop interfaces: `GLib`/`Gio` D-Bus (`org.gnome.Mutter.ScreenCast`, `org.gnome.Mutter.RemoteDesktop`, `org.gnome.Mutter.DisplayConfig`, `org.gnome.ScreenSaver`), `GStreamer` (`pipewiresrc`), `AT-SPI2`, `Pillow`, and optional `tesseract-ocr`, `wl-clipboard`/`xclip`, `grim`, `ydotool`, and `xdotool`.

### Why this beats prompting it yourself
Getting Wayland desktop control right takes weeks of compositor debugging: PipeWire stream handshakes on isolated GLib `MainContext` threads, virtual pointer warm-up so Mutter does not swallow the first click, XKB keysym resolution for shortcuts, CJK clipboard-restore fallback, and fail-closed lock-screen checks. All of that engineering is distilled into five clean, auditable scripts under 20 KB each.

### Use cases
- Automating Ubuntu / Fedora GNOME Wayland desktop apps natively
- Driving headless Linux GUI workstations over SSH or virtual displays
- Testing GTK, Qt, Electron, and browser apps with AT-SPI2 + Tesseract OCR
- Running safe GUI workflows that automatically halt when the screen locks

### Known limitations
- Full GNOME Wayland capture and input require `python3-gi`, `gstreamer1.0-pipewire`, and `python3-pil` installed via the distro package manager.
- Non-GNOME wlroots Wayland compositors use `grim` (screenshots) and `ydotool` (move/click/ASCII typing) fallbacks; full smooth scroll, drag, and key chords are natively supported on GNOME Wayland (`Mutter.RemoteDesktop`) and X11 (`xdotool`).
- Clipboard restoration requires `wl-clipboard` (Wayland) or `xclip` (X11).

## Requires

- Runs on Linux only
- Python 3
- python3-gi
- AT-SPI2
- GStreamer PipeWire (GNOME Wayland)
- Optional: tesseract-ocr

## Technical details

- **Scripts included** (each self-contained, under 20 KB, pure UTF-8 Python 3, zero `shell=True` or `os.system`):
  - `scripts/linux_windows.py` (`capabilities`, `list-windows`, `activate`)
  - `scripts/linux_capture_ocr.py` (`screenshot`, `ocr`)
  - `scripts/linux_ax.py` (`list-apps`, `tree`, `invoke`, `set-value`, `select-text`)
  - `scripts/linux_pointer.py` (`move`, `click`, `drag`, `scroll`)
  - `scripts/linux_keyboard.py` (`press-key`, `type-text`, `paste`)
- **Output format**: Single-line UTF-8 JSON on stdout; structured `{"ok":false,"error":"..."}` on failure (`exit 2` on `SESSION_LOCKED`).
- **Safety**: Zero `shell=True`, zero `os.system`, fail-closed GNOME/login1 lock-screen check, guaranteed `try/finally` key/button release.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Linux Wayland and X11 Desktop Control skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### Does this really work on GNOME Wayland without switching to X11?

Yes. It talks directly to GNOME's Mutter.ScreenCast (via PipeWire + GStreamer) and Mutter.RemoteDesktop D-Bus APIs, plus native AT-SPI2.

### What if I run on Sway, Hyprland, or classic X11?

It automatically falls back to grim + ydotool on wlroots Wayland and xprop/xwininfo/import/xdotool/xclip on X11.

### Does typing non-English (Chinese/Japanese/emoji) text break on Wayland?

No. Non-ASCII input automatically switches to clipboard-preserving Ctrl+V paste and restores your previous clipboard afterward.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
