I think I fixed the import and export clipboard manual buttons. They work for me for now at least.

This commit is contained in:
Storm Dragon
2026-08-17 03:25:57 -04:00
parent 68462d00cb
commit 45019091ab
2 changed files with 27 additions and 3 deletions
+8 -3
View File
@@ -68,11 +68,14 @@ def _run_command(command, display, input_text=None):
input_bytes = None input_bytes = None
if input_text is not None: if input_text is not None:
input_bytes = input_text.encode(_ENCODING) input_bytes = input_text.encode(_ENCODING)
output_target = (
subprocess.PIPE if input_text is None else subprocess.DEVNULL
)
return subprocess.run( return subprocess.run(
command, command,
input=input_bytes, input=input_bytes,
stdout=subprocess.PIPE, stdout=output_target,
stderr=subprocess.PIPE, stderr=output_target,
env=_env_for_display(display), env=_env_for_display(display),
timeout=_CLIPBOARD_TIMEOUT, timeout=_CLIPBOARD_TIMEOUT,
check=False, check=False,
@@ -80,7 +83,9 @@ def _run_command(command, display, input_text=None):
def _command_error(command, result): def _command_error(command, result):
stderr = result.stderr.decode(_ENCODING, errors="replace").strip() stderr = (result.stderr or b"").decode(
_ENCODING, errors="replace"
).strip()
if stderr: if stderr:
return RuntimeError(stderr) return RuntimeError(stderr)
return RuntimeError( return RuntimeError(
+19
View File
@@ -37,6 +37,25 @@ def test_write_text_uses_display_env_without_mutating_process_env(
assert os.environ.get("DISPLAY") is None assert os.environ.get("DISPLAY") is None
@pytest.mark.unit
def test_write_text_does_not_capture_daemonized_writer_pipes(monkeypatch):
monkeypatch.setattr(x_clipboard.shutil, "which", command_exists)
def run_command(command, **kwargs):
if (
kwargs["stdout"] == subprocess.PIPE
or kwargs["stderr"] == subprocess.PIPE
):
raise subprocess.TimeoutExpired(command, 2.0)
return subprocess.CompletedProcess(
command, 0, stdout=None, stderr=None
)
monkeypatch.setattr(x_clipboard.subprocess, "run", run_command)
assert x_clipboard.write_text("clipboard text", ":3") is True
@pytest.mark.unit @pytest.mark.unit
def test_read_text_scans_displays_until_text_is_found(monkeypatch): def test_read_text_scans_displays_until_text_is_found(monkeypatch):
monkeypatch.delenv("DISPLAY", raising=False) monkeypatch.delenv("DISPLAY", raising=False)