Added support for wayland sessions. (#32)

This commit is contained in:
oleksii-kostin
2023-05-07 23:48:58 +02:00
committed by GitHub
parent 250b89fc4a
commit ffdcd7226d

View File

@@ -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'):