mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-30 13:56:31 -04:00
(WSL) Port new clipboard clear behavior to WSL
Former-commit-id: e1d96418abae79f6af75d72eeb6279e661196bd5 Former-commit-id: 0b345de72d9dc13de2f0db7c26264e0deb685965
This commit is contained in:
+6
-3
@@ -542,18 +542,21 @@ def copy_data():
|
||||
# store hashed _copy_subject for later comparison
|
||||
_hash = sha512()
|
||||
_hash.update(_copy_subject.encode('utf-8'))
|
||||
_hash = _hash.hexdigest() + f"{2*' '}-"
|
||||
|
||||
# PORT START CLIPBOARD
|
||||
# WSL clipboard detection
|
||||
if 'WSL_DISTRO_NAME' in environ:
|
||||
run(('powershell.exe', '-c', "Set-Clipboard '" + _copy_subject.replace("'", "''") + "'"))
|
||||
Popen("sleep 30; powershell.exe -c Set-Clipboard ''", shell=True, stdout=DEVNULL, stderr=DEVNULL)
|
||||
Popen("sleep 30; temp=$(echo \"$(powershell.exe -Command \'Get-FileHash -InputStream $([IO.MemoryStream]"
|
||||
"::new([byte[]][char[]]\"$(Get-Clipboard)\")) -Algorithm SHA512 | Select-Object -ExpandProperty "
|
||||
f"Hash\')\" | dos2unix); test \'{_hash.hexdigest().upper()}\' = \"$temp\" && powershell.exe -c "
|
||||
"Set-Clipboard", shell=True, stdout=DEVNULL, stderr=DEVNULL)
|
||||
# Wayland clipboard detection
|
||||
elif 'WAYLAND_DISPLAY' in environ:
|
||||
run('wl-copy', stdin=Popen(('printf', _copy_subject.replace('\\', '\\\\').replace('%', '%%')),
|
||||
stdout=PIPE).stdout)
|
||||
Popen(f"sleep 30; test \'{_hash}\' = \"$(printf \"$(wl-paste)\" | sha512sum)\" && wl-copy -c", shell=True)
|
||||
Popen(f"sleep 30; test \'{_hash.hexdigest() + 2*' ' + '-'}\' = \"$(printf \"$(wl-paste)\" | sha512sum)\" "
|
||||
"&& wl-copy -c", shell=True)
|
||||
# Haiku clipboard detection
|
||||
elif uname()[0] == 'Haiku':
|
||||
run(('clipboard', '-c', _copy_subject))
|
||||
|
||||
Reference in New Issue
Block a user