From ffdcd7226d5c9f212ba12a109c394d5c8029d32c Mon Sep 17 00:00:00 2001 From: oleksii-kostin Date: Sun, 7 May 2023 23:48:58 +0200 Subject: [PATCH] Added support for wayland sessions. (#32) --- manga_ocr/run.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/manga_ocr/run.py b/manga_ocr/run.py index 8a1a74b..1f7910b 100644 --- a/manga_ocr/run.py +++ b/manga_ocr/run.py @@ -63,6 +63,18 @@ def run(read_from='clipboard', mocr = MangaOcr(pretrained_model_name_or_path, force_cpu) + if sys.platform not in ('darwin', 'win32') and write_to == 'clipboard': + # Check if the system is using Wayland + import os + 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) + if read_from == 'clipboard': if sys.platform not in ('darwin', 'win32'):