1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import subprocess
def paste(target=None):
extra_args = []
return subprocess.run(
['xclip', '-sel', 'clip', '-t', 'text/plain', '-o'] + extra_args,
universal_newlines=True,
stdout=subprocess.PIPE
).stdout
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
|