blob: e374479a1889729c18c617c3bbba7bb971da52ef (
plain) (
blame)
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
|
#!/usr/bin/env python3
import sys
import subprocess
import fjdisplay
usage = """fjclip.py src dest. src or dest can be named firejails or - for stdin or stdout.
firemon --x11 to see available running x11 firejails. firejail names can be shortened
to least ambiguous. for example 'work-libreoffice' can be shortened to 'work' if no
other firejails name starts with 'work'.
warning: browsers are dangerous. clipboards from browsers are dangerous. see
https://github.com/dxa4481/Pastejacking
fjclip.py strips whitespace from both
ends, but does nothing else to protect you. use a simple gui text editor like
gedit if you want to see what your pasting."""
if len(sys.argv) != 3 or sys.argv == '-h' or sys.argv == '--help':
print(usage)
exit(1)
if sys.argv[1] == '-':
clipin_raw = sys.stdin.read()
else:
display = fjdisplay.getdisplay(sys.argv[1])
clipin_raw = subprocess.check_output(['xsel', '-b', '--display', display])
clipin = clipin_raw.strip()
if sys.argv[2] == '-':
print(clipin)
else:
display = fjdisplay.getdisplay(sys.argv[2])
clipout = subprocess.Popen(['xsel', '-b', '-i', '--display', display],
stdin=subprocess.PIPE)
clipout.communicate(clipin)
|