]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/services/clipboard_manager.py
Enable OpenGL ES 3.1
[waydroid.git] / tools / services / clipboard_manager.py
1 # Copyright 2021 Erfan Abdi
2 # SPDX-License-Identifier: GPL-3.0-or-later
3 import logging
4 import threading
5 from tools.interfaces import IClipboard
6
7 try:
8 import pyclip
9 canClip = True
10 except Exception as e:
11 logging.debug(str(e))
12 canClip = False
13
14 stopping = False
15
16 def start(args):
17 def sendClipboardData(value):
18 try:
19 pyclip.copy(value)
20 except Exception as e:
21 logging.debug(str(e))
22
23 def getClipboardData():
24 try:
25 return pyclip.paste()
26 except Exception as e:
27 logging.debug(str(e))
28
29 def service_thread():
30 while not stopping:
31 IClipboard.add_service(args, sendClipboardData, getClipboardData)
32
33 if canClip:
34 global stopping
35 stopping = False
36 args.clipboard_manager = threading.Thread(target=service_thread)
37 args.clipboard_manager.start()
38 else:
39 logging.warning("Failed to start Clipboard manager service, check logs")
40
41 def stop(args):
42 global stopping
43 stopping = True
44 try:
45 if args.clipboardLoop:
46 args.clipboardLoop.quit()
47 except AttributeError:
48 logging.debug("Clipboard service is not even started")