From 330396c5f1e1efb7ec3e1c9219e320e4939104a2 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 21 Jun 2022 03:28:56 -0400 Subject: [PATCH] Improved usage of Popen in copy() function + removed import statement for subprocess.STDOUT Former-commit-id: bbc39da1d30845aadac3430b0d8758d6958a159c [formerly 88417f5f6787a5194416256ff3b61733c853cab6] Former-commit-id: 5be7fe4d68ae5153ef1dbde3018b15ed5fe944b0 --- bin/sshyp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/sshyp b/bin/sshyp index fd12658..c80cdb0 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -8,7 +8,7 @@ import random from shutil import get_terminal_size, move, rmtree import sshync import string -from subprocess import CalledProcessError, Popen, PIPE, run, STDOUT +from subprocess import CalledProcessError, Popen, PIPE, run from sys import argv, exit as s_exit from textwrap import fill @@ -589,7 +589,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard system('clipboard -c ' + "'" + _copy_line[2].replace('\n', '').replace("'", "'\\''") + "'") elif argument_list[1] == 'note' or argument_list[1] == '-n': system('clipboard -c ' + "'" + _copy_line[3].replace('\n', '').replace("'", "'\\''") + "'") - Popen('sleep 30; clipboard -r', shell=True) + Popen('sleep 30; clipboard -r', shell=True, close_fds=True) elif Path("/data/data/com.termux").exists(): # Termux (Android) clipboard detection if argument_list[1] == 'username' or argument_list[1] == '-u': system('termux-clipboard-set ' + "'" + _copy_line[1].replace('\n', '').replace("'", "'\\''") + "'") @@ -599,7 +599,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard system('termux-clipboard-set ' + "'" + _copy_line[2].replace('\n', '').replace("'", "'\\''") + "'") elif argument_list[1] == 'note' or argument_list[1] == '-n': system('termux-clipboard-set ' + "'" + _copy_line[3].replace('\n', '').replace("'", "'\\''") + "'") - Popen("sleep 30; termux-clipboard-set ''", shell=True) + Popen("sleep 30; termux-clipboard-set ''", shell=True, close_fds=True) elif environ.get('WAYLAND_DISPLAY') == 'wayland-0': # Wayland clipboard detection if argument_list[1] == 'username' or argument_list[1] == '-u': system('wl-copy ' + "'" + _copy_line[1].replace('\n', '').replace("'", "'\\''") + "'") @@ -609,7 +609,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard system('wl-copy ' + "'" + _copy_line[2].replace('\n', '').replace("'", "'\\''") + "'") elif argument_list[1] == 'note' or argument_list[1] == '-n': system('wl-copy ' + "'" + _copy_line[3].replace('\n', '').replace("'", "'\\''") + "'") - Popen('sleep 30; wl-copy -c', shell=True) + Popen('sleep 30; wl-copy -c', shell=True, close_fds=True) else: # X11 clipboard detection if argument_list[1] == 'username' or argument_list[1] == '-u': system('echo -n ' + "'" + _copy_line[1].replace('\n', '').replace("'", "'\\''") + "'" + ' | xclip -sel c') @@ -619,7 +619,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard system('echo -n ' + "'" + _copy_line[2].replace('\n', '').replace("'", "'\\''") + "'" + ' | xclip -sel c') elif argument_list[1] == 'note' or argument_list[1] == '-n': system('echo -n ' + "'" + _copy_line[3].replace('\n', '').replace("'", "'\\''") + "'" + ' | xclip -sel c') - Popen("sleep 30; echo -n '' | xclip -sel c", shell=True) + Popen("sleep 30; echo -n '' | xclip -sel c", shell=True, close_fds=True) rmtree(f"{tmp_dir}{_shm_folder}")