From 278de2d7f69898b07bdd69edba7d84f9ddf2acab Mon Sep 17 00:00:00 2001 From: Gilles Castel <66gilles99@gmail.com> Date: Fri, 8 Mar 2019 14:16:01 +0100 Subject: Initial commit --- clipboard.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 clipboard.py (limited to 'clipboard.py') diff --git a/clipboard.py b/clipboard.py new file mode 100644 index 0000000..b511313 --- /dev/null +++ b/clipboard.py @@ -0,0 +1,27 @@ +import subprocess + +def copy(string, target=None): + extra_args = [] + if target != None: + extra_args += ['-target', target] + + return subprocess.run( + ['xclip', '-selection', 'c'] + extra_args, + universal_newlines=True, + input=string + ) + +def get(target=None): + extra_args = [] + if target != None: + extra_args += ['-target', target] + + result = subprocess.run( + ['xclip', '-selection', 'c', '-o'] + extra_args, + stdout=subprocess.PIPE, + universal_newlines=True + ) + + # returncode = result.returncode + stdout = result.stdout.strip() + return stdout -- cgit v1.2.3