Set primary selection when dragging with mouse

This commit is contained in:
Kovid Goyal
2016-11-29 11:29:39 +05:30
parent 11182b3682
commit 5ef2c404ce
3 changed files with 58 additions and 9 deletions
+14
View File
@@ -260,3 +260,17 @@ def handle_unix_signals():
signal.siginterrupt(sig, False)
signal.set_wakeup_fd(write_fd)
return read_fd
def get_primary_selection():
# glfw has no way to get the primary selection
# https://github.com/glfw/glfw/issues/894
return subprocess.check_output(['xsel', '-p']).decode('utf-8')
def set_primary_selection(text):
if isinstance(text, str):
text = text.encode('utf-8')
p = subprocess.Popen(['xsel', '-i', '-p'], stdin=subprocess.PIPE)
p.stdin.write(text), p.stdin.close()
p.wait()