Fix formatting of strings being fed through printf for X11 and MacOS

Former-commit-id: 1056b7c8efb6193ce4b43a7d72b2151aabee3559
Former-commit-id: c7b16925d45d3cffba08bac600044954e9561bd8
This commit is contained in:
2023-04-03 22:07:00 -04:00
parent 8fe88a9b14
commit 9063d02cf1
+4 -2
View File
@@ -707,13 +707,15 @@ def copy_data(): # copies a specified field of an entry to the clipboard
run(['clipboard', '-c', _copy_line[_index].rstrip()])
Popen('sleep 30; clipboard -r', shell=True)
elif uname()[0] == 'Darwin': # MacOS clipboard detection
run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip()], stdout=PIPE).stdout)
run(['pbcopy'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\', '\\\\').replace('%', '%%')],
stdout=PIPE).stdout)
Popen("sleep 30; printf '' | pbcopy", shell=True)
elif exists("/data/data/com.termux"): # Termux (Android) clipboard detection
run(['termux-clipboard-set', _copy_line[_index].rstrip()])
Popen("sleep 30; termux-clipboard-set ''", shell=True)
else: # X11 clipboard detection
run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_line[_index].rstrip()], stdout=PIPE).stdout)
run(['xclip', '-sel', 'c'], stdin=Popen(['printf', _copy_line[_index].rstrip().replace('\\', '\\\\')
.replace('%', '%%')], stdout=PIPE).stdout)
Popen("sleep 30; printf '' | xclip -sel c", shell=True)
rmtree(f"{tmp_dir}{_shm_folder}")