From d95b07f09b1c9745fc38df9b0b09ea89849815ea Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 24 Jul 2018 00:35:28 +0200 Subject: [PATCH] Added plugin to manage system clipboard --- docs/source/platypush/plugins/clipboard.rst | 6 ++++ platypush/plugins/clipboard.py | 35 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docs/source/platypush/plugins/clipboard.rst create mode 100644 platypush/plugins/clipboard.py diff --git a/docs/source/platypush/plugins/clipboard.rst b/docs/source/platypush/plugins/clipboard.rst new file mode 100644 index 000000000..c7225dca1 --- /dev/null +++ b/docs/source/platypush/plugins/clipboard.rst @@ -0,0 +1,6 @@ +``platypush.plugins.clipboard`` +=============================== + +.. automodule:: platypush.plugins.clipboard + :members: + diff --git a/platypush/plugins/clipboard.py b/platypush/plugins/clipboard.py new file mode 100644 index 000000000..593c28e97 --- /dev/null +++ b/platypush/plugins/clipboard.py @@ -0,0 +1,35 @@ +import pyperclip + +from platypush.plugins import Plugin, action + + +class ClipboardPlugin(Plugin): + """ + Plugin to programmatically copy strings to your system clipboard + and get the current clipboard content. + + Requires: + * **pyperclip** (``pip install pyperclip``) + """ + + @action + def copy(self, text): + """ + Copies a text to the OS clipboard + + :param text: Text to copy + :type text: str + """ + pyperclip.copy(text) + + + @action + def paste(self): + """ + Get the current content of the clipboard + """ + return pyperclip.paste() + + +# vim:sw=4:ts=4:et: +