From 5633520d82f314916bd1d4f491be98cc4f468dd5 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 23 Oct 2023 10:35:59 -0400 Subject: [PATCH] Fix clipboard clearing on non-Wayland platforms; drop dos2unix as a WSL dependency; suggest openssh-server on Debian and Fedora Former-commit-id: 046786460edc669fa9b962314953164c1cce078e Former-commit-id: d9f0eeb57d73a0255c9dc713533d08d30413bf90 --- lib/clipclear.py | 34 ++++++++++++++++++++++++---------- package.sh | 9 ++++----- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/clipclear.py b/lib/clipclear.py index 3ba9f52..e23f99b 100755 --- a/lib/clipclear.py +++ b/lib/clipclear.py @@ -9,19 +9,33 @@ sleep(30) # store a hash of the current clipboard contents for later comparison _hash_paste = sha512() -_hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) - -# if the supplied hash matches the hash of the current clipboard contents, clear the clipboard -if argv[1] == _hash_paste.hexdigest(): - if argv[2] == 'wsl': +if argv[2] == 'wsl': + _hash_paste.update(run(('powershell.exe', '-c', 'Get-Clipboard'), stdout=PIPE).stdout.strip()) + # if the supplied hash matches the hash of the current clipboard contents, clear the clipboard + if argv[1] == _hash_paste.hexdigest(): run(('powershell.exe', '-c', 'Set-Clipboard')) - elif argv[2] == 'wayland': + +elif argv[2] == 'wayland': + _hash_paste.update(run('wl-paste', stdout=PIPE).stdout.strip()) + if argv[1] == _hash_paste.hexdigest(): run(('wl-copy', '-c')) - elif argv[2] == 'haiku': + +elif argv[2] == 'haiku': + _hash_paste.update(run(('clipboard', '-p'), stdout=PIPE).stdout.strip()) + if argv[1] == _hash_paste.hexdigest(): run(('clipboard', '-r')) - elif argv[2] == 'mac': + +elif argv[2] == 'mac': + _hash_paste.update(run(('pbpaste'), stdout=PIPE).stdout.strip()) + if argv[1] == _hash_paste.hexdigest(): run('pbcopy', input=b'') - elif argv[2] == 'termux': + +elif argv[2] == 'termux': + _hash_paste.update(run(('termux-clipboard-get'), stdout=PIPE).stdout.strip()) + if argv[1] == _hash_paste.hexdigest(): run(("termux-clipboard-set", "''")) - elif argv[2] == 'x11': + +elif argv[2] == 'x11': + _hash_paste.update(run(('xclip', '-o', '-sel', 'c'), stdout=PIPE).stdout.strip()) + if argv[1] == _hash_paste.hexdigest(): run(('xclip', '-i', '/dev/null', '-sel', 'c')) diff --git a/package.sh b/package.sh index 43641dd..42e9bce 100755 --- a/package.sh +++ b/package.sh @@ -222,14 +222,13 @@ Maintainer: Randall Winkhart Description: A light-weight, self-hosted, synchronized password manager Priority: optional Installed-Size: $size +Depends: python3, gnupg, openssh-client " > output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control if [ "$1" = 'Debian' ]; then - printf "Depends: python3, gnupg, openssh-client -Suggests: wl-clipboard, xclip, bash-completion + printf "Suggests: wl-clipboard, xclip, bash-completion, openssh-server " >> output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control else - printf "Depends: python3, gnupg, openssh-client, dos2unix -Suggests: bash-completion + printf "Suggests: bash-completion, openssh-server " >> output/debiantemp/sshyp_"$version"-"$revision"_all/DEBIAN/control fi dpkg-deb --build --root-owner-group -z6 -Sextreme -Zxz output/debiantemp/sshyp_"$version"-"$revision"_all/ @@ -303,7 +302,7 @@ License: GPL-3.0-only URL: https://github.com/rwinkhart/sshyp Source0: GENERIC-FEDORA-sshyp-"$version".tar.xz Requires: python gnupg openssh-clients -Recommends: wl-clipboard xclip bash-completion +Recommends: wl-clipboard xclip bash-completion openssh-server %%description sshyp is a password-store compatible CLI password manager available for UNIX(-like) systems - its primary goal is to make syncing passwords and notes across devices as easy as possible via CLI. %%install