From b1ac3b6438a18fc8578cc7610d9c081321516d0d Mon Sep 17 00:00:00 2001 From: AuroraWright Date: Tue, 23 Jan 2024 10:35:33 +0100 Subject: [PATCH] Switch to a pyperclip fork to fix issues with Linux --- owocr/run.py | 17 +++-------------- requirements.txt | 2 +- setup.py | 4 ++-- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/owocr/run.py b/owocr/run.py index c8602bd..57e8ad9 100644 --- a/owocr/run.py +++ b/owocr/run.py @@ -7,7 +7,7 @@ from pathlib import Path import fire import numpy as np -import pyperclip +import pyperclipfix import asyncio import websockets import queue @@ -180,7 +180,7 @@ def process_and_write_results(engine_instance, engine_color, img_or_path, write_ if write_to == 'websocket': websocket_server_thread.send_text(text) elif write_to == 'clipboard': - pyperclip.copy(text) + pyperclipfix.copy(text) else: write_to = Path(write_to) if write_to.suffix != '.txt': @@ -214,17 +214,6 @@ def run(read_from='clipboard', :param delete_images: Delete image files after processing when reading from a directory. """ - if sys.platform not in ('darwin', 'win32') and write_to == 'clipboard': - # Check if the system is using Wayland - if os.environ.get('WAYLAND_DISPLAY'): - # Check if the wl-clipboard package is installed - if os.system('which wl-copy > /dev/null') == 0: - pyperclip.set_clipboard('wl-clipboard') - else: - msg = 'Your session uses wayland and does not have wl-clipboard installed. ' \ - 'Install wl-clipboard for write in clipboard to work.' - raise NotImplementedError(msg) - engine_instances = [] config_engines = [] engine_keys = [] @@ -429,7 +418,7 @@ def run(read_from='clipboard', except Exception: pass else: - if not just_unpaused and isinstance(img, Image.Image) and (ignore_flag or pyperclip.paste() != '*ocr_ignore*') and ((not generic_clipboard_polling) or (not are_images_identical(img, old_img))): + if not just_unpaused and isinstance(img, Image.Image) and (ignore_flag or pyperclipfix.paste() != '*ocr_ignore*') and ((not generic_clipboard_polling) or (not are_images_identical(img, old_img))): process_and_write_results(engine_instances[engine_index], engine_color, img, write_to, notifications) just_unpaused = False diff --git a/requirements.txt b/requirements.txt index 6a54e87..0448b3f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ jaconv loguru numpy Pillow>=10.0.0 -pyperclip +pyperclipfix pynput websockets notify-py \ No newline at end of file diff --git a/setup.py b/setup.py index 7ba7b57..8a1f3bb 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ long_description = (Path(__file__).parent / "README.md").read_text('utf-8') setup( name="owocr", - version='1.0', + version='1.1', description="Japanese OCR", long_description=long_description, long_description_content_type="text/markdown", @@ -24,7 +24,7 @@ setup( "loguru", "numpy", "Pillow>=10.0.0", - "pyperclip", + "pyperclipfix", "pynput", "websockets", "notify-py"