diff options
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -398,8 +398,7 @@ else: # Running on Linux try: with open(os.devnull, 'w') as DEVNULL: - subprocess.check_call('xclip -o -sel clip', shell=True, stdin=subprocess.PIPE, stdout=DEVNULL, - stderr=DEVNULL) + subprocess.check_call(['uptime', '|', 'xclip'], stdout=DEVNULL, stderr=DEVNULL) can_clip = True except (subprocess.CalledProcessError, OSError, IOError): pass # something went wrong with xclip and we cannot use it @@ -409,8 +408,7 @@ else: :return: str - contents of the clipboard """ - xclipproc = subprocess.Popen('xclip -o -sel clip', shell=True, stdout=subprocess.PIPE, - stdin=subprocess.PIPE) + xclipproc = subprocess.Popen(['xclip', '-o', '-selection', 'clipboard'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = xclipproc.communicate() if six.PY3: return stdout.decode() @@ -422,7 +420,7 @@ else: :param txt: str - text to paste to the clipboard """ - xclipproc = subprocess.Popen('xclip -sel clip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) + xclipproc = subprocess.Popen(['xclip', '-selection', 'clipboard'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) if six.PY3: xclipproc.stdin.write(txt.encode()) else: @@ -430,7 +428,7 @@ else: xclipproc.stdin.close() # but we want it in both the "primary" and "mouse" clipboards - xclipproc = subprocess.Popen('xclip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) + xclipproc = subprocess.Popen(['xclip'], stdout=subprocess.PIPE, stdin=subprocess.PIPE) if six.PY3: xclipproc.stdin.write(txt.encode()) else: |