diff options
| author | Gilles Castel <66gilles99@gmail.com> | 2019-03-08 14:16:01 +0100 |
|---|---|---|
| committer | Gilles Castel <66gilles99@gmail.com> | 2019-03-08 14:16:01 +0100 |
| commit | 278de2d7f69898b07bdd69edba7d84f9ddf2acab (patch) | |
| tree | 0639b63d64ffe24b8835498e44d0adc9656e0fbe /clipboard.py | |
Initial commit
Diffstat (limited to 'clipboard.py')
| -rw-r--r-- | clipboard.py | 27 |
1 files changed, 27 insertions, 0 deletions
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 |
