Skip to content
Snippets Groups Projects
Commit cd25dee5 authored by Galen Abell's avatar Galen Abell Committed by Leo
Browse files

community/pass: patch in support for using wl-clipboard on wayland

parent 9a348376
1 merge request!16519community/pass: patch in support for using wl-clipboard on wayland
......@@ -4,7 +4,7 @@
# Maintainer: Johannes Matheis <jomat+alpinebuild@jmt.gr>
pkgname=pass
pkgver=1.7.3
pkgrel=2
pkgrel=3
pkgdesc="Stores, retrieves, generates, and synchronizes passwords securely"
url="https://www.passwordstore.org"
arch="noarch"
......@@ -20,6 +20,7 @@ subpackages="$pkgname-doc
"
source="https://git.zx2c4.com/password-store/snapshot/password-store-$pkgver.tar.xz
fix-password-generation.patch
wayland-clipboard-backport.patch
README.alpine
"
builddir="$srcdir/password-store-$pkgver"
......@@ -44,4 +45,5 @@ contrib() {
sha512sums="89755a7b02f05d75055a9fc14fd3f456c0a49ec31bdffd097a027f91228c64a98b18c1e80017aeda811773ae3287ff1b9737532da8ded06799d8fe3979ca06f7 password-store-1.7.3.tar.xz
fb2d78975041197f5e9ace5dc2ac8f2de46ebd43ca08c65a527c8c5e5128f0e6baa64a7d994c393777b8a6ddf987f275f815db11359bb787faa89875a508c291 fix-password-generation.patch
0716dff8c119dc951b58e6d340ab20cf469e8ace797c61f492a4c3f4bf68f25d53116f63b62253112e3ccfd4ab65f55aa5cb5793c47445f0d0da346a9c0faac2 wayland-clipboard-backport.patch
eca180d02af608b18a2b6d4b0eaa685c9b1bb8d2ccde921fb27cc12d6d4c31551c6b69fc2ddd2baaa840630ba3c8c0c44ee40b612e8dc004c2b90aafd299a4fa README.alpine"
# Upstream: https://git.zx2c4.com/password-store/commit/?id=b0b784b1a57c0b06936e6f5d6560712b4b810cd3
# Adds support for using pass with wayland via wl-clipboard
diff --git a/README b/README
index 6b59965..1a46242 100644
--- a/README
+++ b/README
@@ -19,8 +19,10 @@ Depends on:
http://www.gnupg.org/
- git
http://www.git-scm.com/
-- xclip
+- xclip (for X11 environments)
http://sourceforge.net/projects/xclip/
+- wl-clipboard (for wlroots Wayland-based environments)
+ https://github.com/bugaevc/wl-clipboard
- tree >= 1.7.0
http://mama.indstate.edu/users/ice/tree/
- GNU getopt
diff --git a/man/pass.1 b/man/pass.1
index 01a3fbe..a555dcb 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -99,6 +99,8 @@ Decrypt and print a password named \fIpass-name\fP. If \fI--clip\fP or \fI-c\fP
is specified, do not print the password but instead copy the first (or otherwise specified)
line to the clipboard using
.BR xclip (1)
+or
+.BR wl-clipboard(1)
and then restore the clipboard after 45 (or \fIPASSWORD_STORE_CLIP_TIME\fP) seconds. If \fI--qrcode\fP
or \fI-q\fP is specified, do not print the password but instead display a QR code using
.BR qrencode (1)
@@ -132,6 +134,8 @@ in generating passwords can be changed with the \fIPASSWORD_STORE_CHARACTER_SET\
If \fI--clip\fP or \fI-c\fP is specified, do not print the password but instead copy
it to the clipboard using
.BR xclip (1)
+or
+.BR wl-clipboard(1)
and then restore the clipboard after 45 (or \fIPASSWORD_STORE_CLIP_TIME\fP) seconds. If \fI--qrcode\fP
or \fI-q\fP is specified, do not print the password but instead display a QR code using
.BR qrencode (1)
@@ -466,6 +470,7 @@ The location of the text editor used by \fBedit\fP.
.BR tr (1),
.BR git (1),
.BR xclip (1),
+.BR wl-clipboard (1),
.BR qrencode (1).
.SH AUTHOR
diff --git a/src/password-store.sh b/src/password-store.sh
index d89d455..284eabf 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -152,16 +152,32 @@ check_sneaky_paths() {
#
clip() {
+ if [[ -n $WAYLAND_DISPLAY ]]; then
+ local copy_cmd=( wl-copy )
+ local paste_cmd=( wl-paste -n )
+ if [[ $X_SELECTION == primary ]]; then
+ copy_cmd+=( --primary )
+ paste_cmd+=( --primary )
+ fi
+ local display_name="$WAYLAND_DISPLAY"
+ elif [[ -n $DISPLAY ]]; then
+ local copy_cmd=( xclip -selection "$X_SELECTION" )
+ local paste_cmd=( xclip -o -selection "$X_SELECTION" )
+ local display_name="$DISPLAY"
+ else
+ die "Error: No X11 or Wayland display detected"
+ fi
+ local sleep_argv0="password store sleep on display $display_name"
+
# This base64 business is because bash cannot store binary data in a shell
# variable. Specifically, it cannot store nulls nor (non-trivally) store
# trailing new lines.
- local sleep_argv0="password store sleep on display $DISPLAY"
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
- local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | $BASE64)"
- echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not copy data to the clipboard"
+ local before="$("${paste_cmd[@]}" 2>/dev/null | $BASE64)"
+ echo -n "$1" | "${copy_cmd[@]}" || die "Error: Could not copy data to the clipboard"
(
( exec -a "$sleep_argv0" bash <<<"trap 'kill %1' TERM; sleep '$CLIP_TIME' & wait" )
- local now="$(xclip -o -selection "$X_SELECTION" | $BASE64)"
+ local now="$("${paste_cmd[@]}" | $BASE64)"
[[ $now != $(echo -n "$1" | $BASE64) ]] && before="$now"
# It might be nice to programatically check to see if klipper exists,
@@ -173,7 +189,7 @@ clip() {
# so we axe it here:
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
- echo "$before" | $BASE64 -d | xclip -selection "$X_SELECTION"
+ echo "$before" | $BASE64 -d | "${copy_cmd[@]}"
) >/dev/null 2>&1 & disown
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment