]> glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/services/clipboard_manager.py
gbinder: Add anbox binders config
[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 def start(args):
15 def sendClipboardData(value):
16 try:
17 pyclip.copy(value)
18 except Exception as e:
19 logging.debug(str(e))
20
21 def getClipboardData():
22 try:
23 return pyclip.paste()
24 except Exception as e:
25 logging.debug(str(e))
26
27 def service_thread():
28 IClipboard.add_service(args, sendClipboardData, getClipboardData)
29
30 if canClip:
31 args.clipboard_manager = threading.Thread(target=service_thread)
32 args.clipboard_manager.start()
33 else:
34 logging.warning("Failed to start Clipboard manager service, check logs")
35
36 def stop(args):
37 try:
38 if args.clipboardLoop:
39 args.clipboardLoop.quit()
40 except AttributeError:
41 logging.debug("Clipboard service is not even started")