2

在 Linux mint 上,我使用以下代码来监控我的剪贴板:

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...")

它工作得很好,除了它经常挂断。我相当确定它check_output在线,因为ps aux表明这xclip -o是一个积极的过程。当我用它杀死它-INT或者-HUP我得到这个回溯时:

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

我做错了什么,还是这里发生了什么错误

4

0 回答 0