Arch Linux 4.16.13, Sublime 3176, xclip 0.13
Hi, I have problem with getting output from xclip commands.
- Only from xclip
- Only when I try to receive output of command
- All problems appears only when I run my python code from sublime plugin
Here is simple plugin setup:
import sublime
import sublime_plugin
from pprint import pprint
class ClipTargets(sublime_plugin.WindowCommand):
def run(self):
cmd = "xclip -o -sel c -t TARGETS"
r = subprocess.check_output(cmd,
shell=True,
universal_newlines=True,
timeout=1
)
pprint(r)
# I'm trying check_output OR Popen.communicate - same problem
# p = subprocess.Popen(cmd,
# stdout=subprocess.PIPE,
# stdin=subprocess.PIPE,
# shell=True
# )
# stdout, stderr = p.communicate(timeout=1)
# pprint(stdout)
In this command I’m try to receive clipboard targets list from current selection. This command is freezes(TimeoutExpired) if I run it when sublime is a clipboard content owner(if last text was copied in sublime). More simpler command xclip -o -sel c
behaves the same way. But I need not just text from clipboard so any sublime or python commands for working with clipboard isn’t suit.
If last copying was performed in any other app, then I receive my targets list.
Why is this happening? How I can bypass this problem? Can I detect that sublime is clipboard content owner before running xclip command?