On Linux mint I'm using the following code to monitor my clipboard:
last_clip = ''
try:
while True:
clip_contents = subprocess.check_output(['xclip', '-o'])
if clip_contents != last_clip:
#write clip_contents to file
time.sleep(0.5)
except KeyboardInterrupt:
print(" Quitting...")
It works great, except for every so often it hangs up. I'm fairly sure it's on the check_output
line, because ps aux
shows that xclip -o
is an active process. And when I kill it with -INT
or -HUP
I get this traceback:
Traceback (most recent call last):
File "get.py", line 16, in <module>
clip_contents = subprocess.check_output(['xclip', '-o'])
File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['xclip', '-o']' returned non-zero exit status -1
Am I Doing something wrong, or is there something buggy going on here?