dsh-hyprscope: Hyprland Desktop Monitoring and Authorized Control

Preface

When building agents with DeepSeek Harness (DSH), a common requirement is to let the agent take over the desktop and perform automated operations. Hyprland, as a popular Wayland compositor, provides rich desktop information and event interfaces, but exposing them directly to an agent poses security risks: the agent may execute unexpected, even destructive, changes.

dsh-hyprscope provides a set of CLI tools and a DSH plugin that make Hyprland desktop observation and authorized control manageable. It observes the desktop in read-only mode, and all mutation operations go through a “lease” mechanism: the plan is frozen before an authorization card pops up, where the user confirms or rejects, and the lease automatically terminates upon TTL expiry or when a revoke hotkey is triggered.

What It Is

dsh-hyprscope is a desktop observation and authorized control tool designed for Hyprland, also integrated into DeepSeek Harness as a native plugin. The project is maintained by LianyeSheng and is part of the DSH ecosystem.

It solves the following problem: enabling agents to operate the desktop within safe boundaries—providing necessary operational capabilities while ensuring every change is explicitly consented to by the user, thereby avoiding unintended consequences from blind execution.

Core Features

Read-Only Observation

  • hyprscope state --json: Get a snapshot of the current desktop state.
  • hyprscope screenshot --output shot.png: Supports screenshots of layouts, monitors, regions, or individual windows.
  • hyprscope events --match 'workspace|activewindow' --count 2 --timeout 5000: Listen for and filter events.

These commands do not depend on additional binaries; they retrieve information solely through Hyprland’s native interfaces.

Authorized Control

  • hyprscope control install-bind: Install a revoke hotkey (default: SUPER + ALT + ESC) to terminate the current operation at any time.
  • hyprscope control run plans/live-terminal.json: Display the authorization card; upon user consent, execute the plan and automatically release control upon completion.
  • hyprscope control status: View the current phase and remaining time.

Lease Mechanism

  • The plan content is frozen before run; the authorization card lists the steps and time budget.
  • TTL limits the runtime duration; the operation is automatically terminated on timeout.
  • Revocation is supported via: hotkey, clicking “Revoke now” on the card, or TTL expiry.
  • If preconditions are not met (e.g., the capability baseline check has not passed), run will refuse execution before showing the card.

Capability Baseline

  • hyprscope control baseline --probe: Probe the current machine’s capabilities and write the results to the Allow file.
  • hyprscope control baseline --show: Display probe results, missing items, and diffs.

Before the baseline is accepted, hyprscope control run will not display the authorization card.

Agent Desktop (Optional)

  • hyprscope control desktop start: Launch a nested window within the current Hyprland session for the agent to work in, while keeping the main session operable.

Installation & Setup

Install from npm (CLI and DSH plugin are bundled together):

npm i -g dsh-hyprscope          # CLI
dsh plugin add dsh-hyprscope    # DSH plugin

Local installation (suitable for debugging or building auxiliary binaries):

git clone https://github.com/LianyeSheng/dsh-hyprscope
cd dsh-hyprscope && pnpm install

Typical Usage

1. Check the Environment

Ensure Node 22 or later, pnpm, and a running Hyprland session.

hyprscope doctor

This command reports session discovery results, compositor version, observable items, and control runtime checks (auxiliary binaries, state directory writability, window capture semantics, etc.).

2. Check the Capability Baseline

node bin/hyprscope.ts control baseline --probe

If the probe results require extending the baseline, the command will prompt and write to the Allow file.

3. Execute Authorized Control

node bin/hyprscope.ts control install-bind
node bin/hyprscope.ts control run plans/live-terminal.json

After execution, an authorization card appears in the center of the screen. Once the user confirms, the plan runs. During execution, the card shrinks to a top banner displaying remaining time and a revoke button. Control is automatically released upon completion.

4. Check Status

node bin/hyprscope.ts control status

5. Use Auxiliary Binaries (Optional)

Some advanced features depend on native C helper programs, which can be generated via build scripts:

pnpm run build:probe
pnpm run build:inject
pnpm run build:capture
pnpm run build:scratch
  • bin/wl-inject: Pointer and keyboard injection.
  • bin/wl-capture: Single-window capture (depends on the ext-image-copy-capture protocol).
  • bin/wl-scratch: A scratch window used by the probe.

Use Cases & Notes

  • Ideal for DSH agent developers who need Hyprland desktop automation.
  • The plugin runs with the permissions of the current DSH process. Review the source code and license (MIT) before installing.
  • Some features (such as single-window capture) depend on Hyprland’s extension protocols; testing on version 0.57.2 or later is recommended.

Conclusion

dsh-hyprscope provides a secure, auditable control path for Hyprland desktops, enabling agents to perform automated operations under explicit authorization. For more details and source code, refer to the project homepage and GitHub repository.

  • Directory page: https://www.skillhub.cn/plugins/LianyeSheng/dsh-hyprscope
  • GitHub: https://github.com/LianyeSheng/dsh-hyprscope
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye