MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _set_clipboard

Function _set_clipboard

src/command_system/copy_command.py:157–174  ·  view source on GitHub ↗

Best-effort OS clipboard via subprocess; True on success.

(text: str)

Source from the content-addressed store, hash-verified

155
156
157def _set_clipboard(text: str) -> bool:
158 """Best-effort OS clipboard via subprocess; True on success."""
159 if sys.platform == "darwin":
160 candidates = [["pbcopy"]]
161 elif sys.platform.startswith("win"):
162 candidates = [["clip"]]
163 else:
164 candidates = [["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]]
165 for cmd in candidates:
166 try:
167 proc = subprocess.run(
168 cmd, input=text.encode("utf-8"), capture_output=True, timeout=5
169 )
170 if proc.returncode == 0:
171 return True
172 except Exception:
173 continue
174 return False
175
176
177def _write_to_file(text: str, filename: str) -> str:

Callers 1

_copy_or_writeFunction · 0.85

Calls 2

encodeMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected