Switch to a pyperclip fork to fix issues with Linux
This commit is contained in:
17
owocr/run.py
17
owocr/run.py
@@ -7,7 +7,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
import fire
|
import fire
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyperclip
|
import pyperclipfix
|
||||||
import asyncio
|
import asyncio
|
||||||
import websockets
|
import websockets
|
||||||
import queue
|
import queue
|
||||||
@@ -180,7 +180,7 @@ def process_and_write_results(engine_instance, engine_color, img_or_path, write_
|
|||||||
if write_to == 'websocket':
|
if write_to == 'websocket':
|
||||||
websocket_server_thread.send_text(text)
|
websocket_server_thread.send_text(text)
|
||||||
elif write_to == 'clipboard':
|
elif write_to == 'clipboard':
|
||||||
pyperclip.copy(text)
|
pyperclipfix.copy(text)
|
||||||
else:
|
else:
|
||||||
write_to = Path(write_to)
|
write_to = Path(write_to)
|
||||||
if write_to.suffix != '.txt':
|
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.
|
: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 = []
|
engine_instances = []
|
||||||
config_engines = []
|
config_engines = []
|
||||||
engine_keys = []
|
engine_keys = []
|
||||||
@@ -429,7 +418,7 @@ def run(read_from='clipboard',
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
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)
|
process_and_write_results(engine_instances[engine_index], engine_color, img, write_to, notifications)
|
||||||
|
|
||||||
just_unpaused = False
|
just_unpaused = False
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ jaconv
|
|||||||
loguru
|
loguru
|
||||||
numpy
|
numpy
|
||||||
Pillow>=10.0.0
|
Pillow>=10.0.0
|
||||||
pyperclip
|
pyperclipfix
|
||||||
pynput
|
pynput
|
||||||
websockets
|
websockets
|
||||||
notify-py
|
notify-py
|
||||||
4
setup.py
4
setup.py
@@ -5,7 +5,7 @@ long_description = (Path(__file__).parent / "README.md").read_text('utf-8')
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="owocr",
|
name="owocr",
|
||||||
version='1.0',
|
version='1.1',
|
||||||
description="Japanese OCR",
|
description="Japanese OCR",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
@@ -24,7 +24,7 @@ setup(
|
|||||||
"loguru",
|
"loguru",
|
||||||
"numpy",
|
"numpy",
|
||||||
"Pillow>=10.0.0",
|
"Pillow>=10.0.0",
|
||||||
"pyperclip",
|
"pyperclipfix",
|
||||||
"pynput",
|
"pynput",
|
||||||
"websockets",
|
"websockets",
|
||||||
"notify-py"
|
"notify-py"
|
||||||
|
|||||||
Reference in New Issue
Block a user