User Guide

Application-Specific Policy Rules

Configure per-app retrieval modes, hotkey-only triggers, deny-paste downgrades, and pre-retrieval gates.

On this page (8 sections)

OpenClip allows configuring application-specific behavior rules through AppRule and RuleEngine. App rules control how OpenClip retrieves text and delivers it (paste vs copy) when specific target macOS applications are active.


JSON Configuration Format (rules.json)#

Rules are stored in JSON configuration files (such as ~/.openclip/rules.json) conforming to RuleEngineConfig:

jsonc
{
  "rules": [
    {
      "bundle-identifiers": ["com.example.game"],
      "disabled": true
    },
    {
      "bundle-identifiers": ["com.example.editor"],
      "hotkey-only": true
    },
    {
      "bundle-identifiers": ["com.example.terminal"],
      "deny-paste": true,
      "retrieval-mode": "menu-copy"
    },
    {
      "bundle-identifiers": ["com.example.app"],
      "gate": {
        "skipRoles": [],
        "allowedCursors": ["beam", "arrow", "pointingHand", "unknown"]
      }
    }
  ]
}

Policy Properties Reference#

Property Key in JSONCode IdentifierTypeDescription
bundle-identifiersbundleIdentifiersArrayTarget application identifier patterns: bundle IDs, process:<name> / path:<executable> scoped patterns for apps without a bundle ID, wildcards, or group aliases.
disableddisabledBoolWhen true, completely disables OpenClip in the target application (no popup, hotkeys ignored).
hotkey-onlyhotkeyOnlyBoolWhen true, suppresses automatic popup on text selection; OpenClip will only trigger when explicitly invoked via global hotkey (⌥⌘C).
deny-pastedenyPasteBoolForce text delivery to be a copy instead of a paste, even when the app advertises a Paste command (e.g. terminals).
retrieval-moderetrievalModeEnumWhich mechanism reads the selection. One of ax-text-control (default), ax-web-area, browser-script, menu-copy, keyboard-copy (see below).
gategateObjectPre-retrieval gate rules — skipRoles (AX roles never allowed to hold a selection) and allowedCursors (cursor classes that suggest a text context). See SelectionGatePolicy.
use-menu-copyuseMenuCopyBoolLegacy alias. true resolves to retrieval-mode: "menu-copy" (read via the AX Edit ▸ Copy menu item) only when the rule sets no retrieval-mode and no higher-priority builtin retrieval mode applies (the app isn't already assigned a different mode by the builtin catalog). Prefer retrieval-mode in new rules.

retrieval-mode values#

ValueStrategyTarget Context
ax-text-controlDirect AX read of kAXSelectedTextAttribute — zero pasteboard side-effects. Default.Standard native text controls
ax-web-areaAX web-area read via text-marker ranges, with a settle-retry loop and deep DOM walk.Web browsers (Safari, Chrome, Firefox, Arc) and embedded web content
browser-scriptLegacy alias. Formerly executed AppleScript in browsers; now maps directly to ax-web-area with keyboard-copy fallback for sub-millisecond selection without automation permission prompts.Supported web browsers
menu-copyAXPress the Edit ▸ Copy menu item, then archive-and-restore the pasteboard.Terminal emulators and CLI tools
keyboard-copySynthesized ⌘C key event, then archive-and-restore the pasteboard.Custom code editors and Electron apps

These modes match the per-app defaults assigned by the builtin catalog (DefaultAppRules.catalog); a user rule only overrides the keys it sets, so e.g. gate alone leaves retrieval-mode at the app's default.


Identifier Matching & Shortcuts#

Bundle IDs#

Plain entries match the target application's bundle identifier. Apps without one — CLI tools and SDL apps such as scrcpy — are targeted by scoped identifiers:

  • "process:scrcpy" matches the process's executable or localized name. Case-insensitive; * wildcards work ("process:scr*").
  • "path:/opt/homebrew/bin/scrcpy" matches the executable path; * wildcards work ("path:/opt/tools/*").

The App Rules page and the menu bar's Pause in &lt;App&gt; item write process: rules automatically for bundle-less apps.

Wildcard Pattern Matching#

RuleEngine supports prefix wildcard matching using .* or global wildcard *:

  • "com.example.*" matches com.example.app1, com.example.app2, etc.
  • "*" matches all applications, including bundle-less ones.

Builtin Group Expansion Aliases#

Group ShortcutDescription
:menu-copy-apps:Expands to all terminal applications configured for menu-based copy in DefaultAppRules.menuCopyApps.

Rule Evaluation Mechanics#

  1. When a selection event is detected, the trigger sites (MacSelectionMonitor, HotkeyManager) query RuleEngine.shared.resolvePolicies(for: appIdentity).
  2. RuleEngine matches the target application's identity against effective rules (default rules + user rules): plain patterns against the bundle ID, process: patterns against the process name, path: patterns against the executable path, with .*-prefix / * wildcards.
  3. Matched policy settings override default AppPolicyContext values; the resolved retrieval-mode and gate are passed to SelectionRetrievalCoordinator to read the selection.
  4. A legacy use-menu-copy: true rule resolves to retrieval-mode: "menu-copy" only when the rule sets no explicit retrieval-mode and no higher-priority builtin retrieval mode applies (the app isn't already assigned a different mode by the builtin catalog).
  5. If denyPaste: true is active for the frontmost application, paste delivery is downgraded to copy and the Paste/Cut actions are hidden from the floating popup bar (via the unified PasteAvailability decision).