refactor(#2305): drop mouse tools + ydotool, switch key_press to wtype
- remove mouse_move and mouse_click (no Wayland-native alternative on Weston without /dev/uinput; follow-up filed for future investigation) - replace key_press from 'ydotool key' to 'wtype -k': parses mod1+mod2+key into -M mod1 ... -k key ... -m mod1 sequence via virtual-keyboard protocol - remove dest_path parameter from screenshot: always writes to /tmp/ (fixes arbitrary write-path concern from security review) - simplify screen.nix: drop screenInput option, ydotoold systemd unit, ydotool package; only grim + wtype remain (both compositor-mediated, no /dev/uinput) - update module header comment to reflect three-tool surface Addresses mara's /dev/uinput veto (PR #2617 comment #40524).
This commit is contained in:
parent
584dfed0c9
commit
7fa7e2bdfd
2 changed files with 55 additions and 154 deletions
|
|
@ -1,15 +1,13 @@
|
|||
# Screen MCP — screenshot + input injection for GUI agents.
|
||||
# Screen MCP — screenshot + keyboard input for GUI agents.
|
||||
#
|
||||
# Auto-activated when `hyperhive.gui.enable = true`. Wires the
|
||||
# `hive-screen-mcp` stdio bridge as `extraMcpServers.screen` so claude
|
||||
# gets five tools: `screenshot`, `type_text`, `key_press`, `mouse_move`,
|
||||
# and `mouse_click`.
|
||||
# gets three tools: `screenshot`, `type_text`, and `key_press`.
|
||||
#
|
||||
# `screenshot` and `type_text` work out of the box (grim + wtype, both
|
||||
# pure Wayland clients). `key_press`, `mouse_move`, and `mouse_click`
|
||||
# require the ydotoold daemon, which injects events via `/dev/uinput`
|
||||
# at the kernel level — enable it by setting
|
||||
# `hyperhive.gui.screenInput = true`.
|
||||
# All tools use Wayland protocols mediated by the Weston compositor —
|
||||
# no `/dev/uinput` or kernel-level injection needed. `grim` takes
|
||||
# screenshots; `wtype` handles both text input and key/modifier combos
|
||||
# via the `zwp-virtual-keyboard-unstable-v1` protocol.
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
|
|
@ -17,20 +15,6 @@
|
|||
...
|
||||
}:
|
||||
{
|
||||
options.hyperhive.gui.screenInput = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Enable mouse and keyboard injection via ydotool + the ydotoold
|
||||
daemon. Requires `/dev/uinput` device access inside the container
|
||||
(the host must bind it in via `extraSystemdProperties` or
|
||||
`systemd.nspawn.<name>.filesConfig.Bind`). When false,
|
||||
`screenshot` and `type_text` still work; `key_press`,
|
||||
`mouse_move`, and `mouse_click` return an error from ydotool
|
||||
until ydotoold is running and `/dev/uinput` is accessible.
|
||||
'';
|
||||
};
|
||||
|
||||
config = lib.mkIf config.hyperhive.gui.enable {
|
||||
# Register the screen MCP bridge so claude gets the screen tools.
|
||||
hyperhive.extraMcpServers.screen = {
|
||||
|
|
@ -38,27 +22,11 @@
|
|||
args = [ ];
|
||||
};
|
||||
|
||||
# grim: Wayland screenshot; wtype: text/key input (no daemon).
|
||||
# ydotool: mouse + key injection via uinput (needs screenInput).
|
||||
# grim: Wayland screenshot; wtype: text + key input via virtual-keyboard
|
||||
# protocol (compositor-mediated, no /dev/uinput required).
|
||||
environment.systemPackages = [
|
||||
pkgs.grim
|
||||
pkgs.wtype
|
||||
]
|
||||
++ lib.optional config.hyperhive.gui.screenInput pkgs.ydotool;
|
||||
|
||||
# ydotoold — uinput event injection daemon. The socket lands at
|
||||
# /tmp/.ydotool_socket by default; ydotool picks it up
|
||||
# automatically. Only started when screenInput is enabled.
|
||||
systemd.services.ydotoold = lib.mkIf config.hyperhive.gui.screenInput {
|
||||
description = "ydotool input injection daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "local-fs.target" ];
|
||||
serviceConfig = {
|
||||
ExecStart = "${pkgs.ydotool}/bin/ydotoold";
|
||||
Restart = "on-failure";
|
||||
RestartSec = "2s";
|
||||
SyslogIdentifier = "ydotoold";
|
||||
};
|
||||
};
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue