close
Skip to content
CLOUDWERX-DEVPublic

About

A fast Rust tool that gives coding agents your real mouse and keyboard on Linux, behind an allow/deny prompt you control. niri, Hyprland, sway, KDE, GNOME, X11.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Ghosthand

version license rust platform tests

Digital Food for the Analog Soul
by CLOUDWERX LAB


Ghosthand lets a coding agent use your real mouse and keyboard on Linux. Right click a menu, drag something, hover a tooltip, scroll a list, type into a field, hit a shortcut, then take a screenshot and see what happened. It was built for niri on Arch and CachyOS, because that's what I run, and that's where it's been tested the most. It's meant to work on X11, Hyprland, sway, KDE and GNOME too (the table below is honest about what's been verified).

The part I care about most is the gate. Before anything moves or types, a card shows up on your screen saying who's asking, why, and exactly what it's about to type. Nothing happens until you click Allow. No answer counts as a no. While the agent is driving, a little "Agent Control" tag and a ring follow the cursor so you always know it's not you. One key takes the pointer back at any time.

The allow/deny card, and the tag that follows the cursor
An illustration of the card and the tag, not a screenshot of a real desktop.

Why it exists

I got tired of agents that could write a whole UI but couldn't open a right-click menu on it. Screenshots tell you what's there. They can't tell you what happens when you hover or drag. So the agent has to be able to use the pointer, and I had to be able to trust that it only does that when I say so.

How it works under the hood is simple. Ghosthand creates a virtual absolute pointer through /dev/uinput, so the display server sees a normal mouse. That's why it isn't tied to one compositor: no portals, no compositor plugins, no X11 libraries. The card and tag are a small Quickshell config (Wayland), or a plain zenity/yad/kdialog dialog where Quickshell can't run. Everything else is one small Rust binary.

What you get

  • A real pointer. Click, double click, right click, middle click, drag, right drag, scroll both ways, hover.
  • A real keyboard. Type text, press shortcuts (ctrl+shift+t), hold keys while you click, paste what can't be typed. It reads your actual keyboard layout (QWERTY, AZERTY, Dvorak, German and so on) so it types what it should. Details.
  • Knows where keys will land. focus prints the focused window, so an agent can check before it types.
  • A gate. Allow, Allow for N minutes, or Deny, on a card with a countdown. Or one approval for a whole session. Silence is a no. The card shows what will be typed, and allowing the mouse never allows the keyboard.
  • A visible tag and ring that follow the cursor while an agent drives it (with the Quickshell overlay, see below).
  • A panic key. ghosthand revoke stops a running agent, ends any grant and closes the card. Bind it to a key.
  • Screen coordinates that match screenshots. You give it pixels from a grim screenshot and it handles the scale.
  • Themeable. The card, pill, ring and tag read their colours from an optional ~/.config/ghosthand/theme.json and follow it live (docs).
  • An agent skill, so an agent can learn to use it from the shell with no MCP at all. ghosthand skill install drops it in place (--all for every agent you have). Agent rules: ghosthand rules install keeps a short block in your agents' global instructions files, so an agent is told to ask for one session instead of a card per call before it makes its first call (docs).
  • An MCP server on the current spec (2026-07-28), and older clients still work. There's no tool to approve a request. That part's yours.
  • A lock check. It refuses to run while your session is locked, and if it can't tell, it counts as locked.
  • Works where you are. Screenshots and screen size are detected for niri, Hyprland, sway, X11 and the rest, see below.
  • Fast. One static-ish Rust binary (about 1 MB, four direct dependencies). Devices are kept alive by a background daemon, so after the first call a run starts in milliseconds instead of waiting a second for a new virtual device. See the numbers.

Where it works

Note

Quickshell is optional. Without it Ghosthand asks you with a plain dialog (zenity, yad or kdialog), or with a notification that has Allow and Deny buttons, and everything else works the same. You only lose the cursor tag and ring. Nothing here needs any particular desktop shell.

Two parts, and they're independent: the pointer (uinput, works on anything) and the asking (the card). The card uses Quickshell on Wayland, or a dialog everywhere else.

Session Pointer Screenshots Screen size The card Tested
niri yes grim niri msg Quickshell overlay + tag yes, daily
Hyprland yes grim hyprctl Quickshell overlay + tag parsers tested, not run live
sway, river, other wlroots yes grim swaymsg / wlr-randr Quickshell overlay + tag parsers tested, not run live
KDE Plasma (Wayland) yes spectacle screenshot size overlay (layer-shell) or dialog not tested
GNOME (Wayland) yes gnome-screenshot screenshot size dialog (no layer-shell) not tested
X11 yes maim, scrot or ImageMagick xrandr dialog parsers tested, not run live

"Parsers tested" means the code that reads each tool's output is covered by tests with real output samples, but I haven't driven those desktops myself. If you run one of them, ghosthand doctor and a bug report or a pull request with what happened would help a lot. On X11 and GNOME the card is a dialog and there's no cursor tag, a notification tells you the pointer's in use instead.

Multiple monitors: coordinates are for the output Ghosthand reports (ghosthand info). Compositors map a virtual absolute pointer across all outputs by default, so on a multi-monitor setup you'll want to pin it to one. Notes for Hyprland and sway are in the setup docs.

Install

You need a screenshot tool for your session (grim on Wayland, maim, scrot or ImageMagick on X11). For the card, either Quickshell (Wayland with layer-shell) or one of zenity, yad or kdialog.

# from source (Rust 1.74 or newer)
cargo install --git https://github.com/CLOUDWERX-DEV/Ghosthand

# or grab a binary from the releases page and put it on your PATH

ghosthand setup             # puts the overlay in ~/.config/quickshell/ghosthand (skip it if you'll use a dialog)

Then give your user access to /dev/uinput. This is the one step that needs root, once:

sudo cp packaging/99-ghosthand-uinput.rules /etc/udev/rules.d/
sudo udevadm control --reload && sudo udevadm trigger /dev/uinput
sudo usermod -aG input "$USER"      # log out and back in

Start the overlay (skip this on X11/GNOME, the dialog needs nothing running) and check everything:

ghosthand overlay &         # or autostart it, see docs/setup.md
ghosthand doctor

doctor tells you which screenshot tool, screen-size source and card it picked. With "gate": "auto" (the default) it uses the overlay when it's running and a dialog when it isn't.

On Arch there's a PKGBUILD too.

Use it

Each action is one quoted argument. Coordinates are pixels in a grim screenshot.

ghosthand --who Claude --reason "Checking the bar menu" \
  'jump 800 26' 'wait 0.4' 'rclick' 'wait 0.8' 'shot /tmp/menu.png'
Action What it does
jump X Y put the pointer there at once
move X Y glide there in small steps, so hover states follow
click dclick rclick mclick [X Y] click where it is, or at X Y
down up rdown rup hold and release a button
drag X1 Y1 X2 Y2 press, glide, release (rdrag uses the right button)
scroll N [X Y] hscroll N [X Y] wheel notches, positive scrolls the content down
wait SECONDS sleep for animations (a revoke still stops it)
shot FILE [X Y W H] screenshot of the output or a region
pos info where the pointer is, and the output's size and scale
focus the focused window as JSON, so you know where keys will land
key COMBO... press keys and chords in order: key ctrl+s, key Escape, key Tab Tab Return
keydown COMBO keyup COMBO hold and release keys, for Shift+click and friends
type TEXT type text with your real layout (\n is Enter, \t is Tab)
paste TEXT clipboard plus Ctrl+V for text type can't make, like emoji. The clipboard is put back

Typing works the same way. Click the field first, because keys go to whatever has focus:

ghosthand --who Claude --reason "Searching the launcher for the settings app" \
  'key super+space' 'wait 0.5' 'focus' 'type settings' 'wait 0.4' 'shot /tmp/search.png'

Typos, unknown keys, and characters your layout can't type are caught before anything moves or is typed, so a bad action can't leave you half way through a drag or a sentence. If something goes wrong or you revoke, held buttons are released.

Exit codes: 0 done, 1 an action failed or the session is locked, 2 bad usage, 3 taken back, 4 denied or no answer, 5 the overlay can't be reached.

Teach an agent with the skill (no MCP needed)

There's a proper agent skill in skills/ghosthand. It covers the look, aim, act, check loop, coordinates, every action, how to behave at the gate, and what the exit codes mean. Install it where your agent looks for skills:

ghosthand skill install                       # ~/.claude/skills/ghosthand (Claude Code)
ghosthand skill install ~/.agents/skills      # or any skills folder (Codex, shared agents, ...)
ghosthand skill install --all                 # every agent folder that exists (Claude Code, Codex, Antigravity, opencode, ~/.agents)
ghosthand rules install                       # the short rules block, in every global agent file that exists

After that the agent just runs the ghosthand command from its shell.

Or use it over MCP

{
  "mcpServers": {
    "ghosthand": { "command": "ghosthand", "args": ["mcp"] }
  }
}

Claude Code: claude mcp add ghosthand -- ghosthand mcp

The tools are pointer, screenshot, screen_info and gate_status. pointer needs a reason, because that's what you read on the card. screenshot doesn't need approval since it never touches the pointer. The server speaks the current MCP spec (2026-07-28, stateless, with server/discover) and still answers initialize for clients on 2025-11-25 and older. More in the docs.

Bind the panic key

For niri, add this to your config (the full snippet is in packaging/niri-snippet.kdl):

binds {
    Mod+Ctrl+Alt+Escape allow-inhibiting=false { spawn "ghosthand" "revoke"; }
}

Sessions: one approval for a stretch of work

For a long job, like testing a UI for half an hour with clicks and typing mixed together, asking on every call gets old. A session asks once:

ghosthand session start --reason "UI testing the settings app" --for 30m
# one card: "Claude wants to use your mouse and keyboard", the reason, "session for 30 min", [Deny] [Allow]
ghosthand 'click 400 300' 'type hello' 'key Return'   # no more cards
ghosthand session end                                 # or revoke, or the time runs out

While it's on, a pill stays on your screen ("Agent Control · mouse and keyboard · 24:10 left" with an End button), so you can always see it, and end it, without a command. It ends by itself when the time is up, after 10 minutes of nobody using it (--idle), when you revoke, or when the screen locks.

A session covers only what you approved: a --scope mouse session never lets anything type. Asking for one is something an agent can do (there's a session MCP tool), but only you can say yes. The dialog fallback shows the same card without "Allow for N min" and uses notifications instead of the pill. More in docs/sessions.md.

Config

~/.config/ghosthand/config.json, read by the overlay, and only by the overlay. A program asking for the pointer can't change any of it.

{
  "mode": "ask",
  "countdown": 8,
  "grant_minutes": 10,
  "accent": "#3de0ff"
}
  • mode: ask (must be allowed, default), notify (a countdown that goes ahead unless you deny) or off (no card, the tag still shows).
  • countdown: seconds the card waits, 2 to 60. An agent can ask for longer, never shorter.
  • grant_minutes: what "Allow for N min" grants, 1 to 240.
  • accent, ui_scale: the look (overlay).
  • gate: auto (default), overlay or dialog.
  • screenshot: a command that writes a PNG to {file}, if you want to use your own tool.

More in docs/configuration.md.

How it compares

There are other tools doing nearby things, and some are very good. I'm not going to claim I beat them at anything, because I haven't benchmarked it. Here's the honest version of how they differ:

  • Cua Drivers is a big, polished project that covers sandboxes, VMs and more across platforms. If you want that scope, use it. Ghosthand is much smaller and only does the local pointer on Wayland.
  • computer-use-linux, Deskwright and hypruse also give agents a desktop to drive. If you're on Hyprland or want accessibility trees or window control, look at those first.

What Ghosthand focuses on is the human side of it: a gate you answer, a tag you can't miss, and a key that takes everything back. And it's built around niri, where I got tired of nothing quite fitting. It's also small: you can read the whole thing in an afternoon.

Limits, said plainly

  • It isn't a security boundary. It's a courtesy gate. An agent with a shell and write access to /dev/uinput can skip Ghosthand and make its own pointer. The gate protects you from an agent that's behaving, not one that's hostile. If you need a hard boundary, run the agent somewhere that doesn't have /dev/uinput. Read SECURITY.md.
  • Typing into a terminal runs commands. That's the point of the card showing you exactly what will be typed. Read it before you click Allow.
  • Keys go to the focused window. Ghosthand can't aim them. focus tells the agent where they'll land, and it's on the agent to click the field first.
  • The tag needs the Quickshell overlay. The dialog fallback asks you the same question but can't draw a ring or tag. GNOME has no layer-shell, so it's dialog only there.
  • Only niri has been run for real. The others are built from each tool's documented output and tested against samples. See the table above.
  • Absolute pointer on several monitors needs pinning to one output on some compositors (docs/setup.md).
  • A running pointer call can't be cancelled by the MCP client, since it's a blocking call. Use ghosthand revoke.

How fast is it?

A new virtual input device takes about a second to be picked up by the compositor. The first version paid that on every single call. Now the first call starts ghosthand daemon in the background, which keeps the devices alive and forwards events from later calls over a Unix socket (mode 0600). It exits by itself after two minutes of nobody using it, and lets go of any key or button a dead client was holding. The gate is not in the daemon, it stays in every run.

Revoke checks used to start a process between every action. They're a file check now.

Measured on my machine (niri, one pointer and keyboard, the same three calls through both versions, in a throwaway runtime directory). Version 0.2.0 was the first to be written in a different language and the speedup is mostly the daemon, not the language:

Call 0.2.0 (devices made on every call) 0.3.0 (daemon)
first call: jump, click, type 2.56 s 1.34 s (the devices are made once, together)
second call, a few seconds later 2.51 s 0.26 s
pos 1.29 s 0.03 s

Turn the daemon off with "daemon": false in the config if you'd rather every run made its own devices (the old behavior). daemon_idle_seconds changes how long it lingers, 0 keeps it running.

Develop

cargo test
cargo clippy --all-targets

The unit tests use fake devices and the CLI tests run the real binary in a throwaway directory, so nothing touches your desktop and uinput isn't needed. examples/live_test.rs checks the real devices without anything reaching your desktop (it grabs them exclusively). CONTRIBUTING.md has the rest.

Support

If it's useful to you, you can buy me a coffee. More from us at cloudwerxlab.com and github.com/CLOUDWERX-DEV.

MIT licensed. See LICENSE.

About

A fast Rust tool that gives coding agents your real mouse and keyboard on Linux, behind an allow/deny prompt you control. niri, Hyprland, sway, KDE, GNOME, X11.

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages