from subprocess import Popen, PIPE
def copy_clipboard(msg):
''' Copy `msg` to the clipboard '''
with Popen(['xclip','-selection', 'clipboard'], stdin=PIPE) as pipe:
pipe.communicate(input=msg.encode('utf-8'))
# Copy some text to the clipboard
copy_clipboard('This is a test')
Created
October 11, 2019 22:14
-
-
Save ShannonScott/50ffcd12e134b83a8680835a838dcfc0 to your computer and use it in GitHub Desktop.
[Python Copy Text to Clipboard] Copy Text to the Linux / X Clipboard. #tags: linux, python
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment