[PATCH 1/1] Add support for gpaste as clipper

Peter A. Bigot pab at pabigot.com
Wed Jan 28 12:28:21 UTC 2026


gpaste is a Gnome-specific clipboard solution with history.  Unlike
wl-copy, it does not rely on being able to take focus to access the
clipboard, so it works for users who prefer focus-new-windows=strict
(vice "smart") under Wayland.

Signed-off-by: Peter A. Bigot <pab at pabigot.com>
---
 man/pass.1            | 11 ++++++++++-
 src/password-store.sh | 14 +++++++++++---
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/man/pass.1 b/man/pass.1
index a555dcb..5af8111 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -99,8 +99,11 @@ 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)
+or
+.BR gpaste-client(1)
+(if \fIPASSWORD_STORE_USE_GPASTE\fP is set)
 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)
@@ -429,6 +432,11 @@ for more info.
 Specifies the number of seconds to wait before restoring the clipboard, by default
 \fI45\fP seconds.
 .TP
+.I PASSWORD_STORE_USE_GPASTE
+Set this to any non-empty value to prefer
+.BR gpaste-client (1)
+over other clipping agents, if available.
+.TP
 .I PASSWORD_STORE_UMASK
 Sets the umask of all files modified by pass, by default \fI077\fP.
 .TP
@@ -471,6 +479,7 @@ The location of the text editor used by \fBedit\fP.
 .BR git (1),
 .BR xclip (1),
 .BR wl-clipboard (1),
+.BR gpaste-client (1),
 .BR qrencode (1).
 
 .SH AUTHOR
diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..f6985c8 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -16,6 +16,7 @@ PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
 EXTENSIONS="${PASSWORD_STORE_EXTENSIONS_DIR:-$PREFIX/.extensions}"
 X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}"
 CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}"
+USE_GPASTE="${PASSWORD_STORE_USE_GPASTE:+yes}"
 GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}"
 CHARACTER_SET="${PASSWORD_STORE_CHARACTER_SET:-[:punct:][:alnum:]}"
 CHARACTER_SET_NO_SYMBOLS="${PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS:-[:alnum:]}"
@@ -155,7 +156,10 @@ check_sneaky_paths() {
 #
 
 clip() {
-	if [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
+	if [[ -n $USE_GPASTE ]] && command -v gpaste-client &> /dev/null; then
+		local copy_cmd=( gpaste-client add-password $2 )
+		local paste_cmd=( : )
+	elif [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
 		local copy_cmd=( wl-copy )
 		local paste_cmd=( wl-paste -n )
 		if [[ $X_SELECTION == primary ]]; then
@@ -168,7 +172,7 @@ clip() {
 		local paste_cmd=( xclip -o -selection "$X_SELECTION" )
 		local display_name="$DISPLAY"
 	else
-		die "Error: No X11 or Wayland display and clipper detected"
+		die "Error: No X11 or Wayland display and clipper or gpaste-client detected"
 	fi
 	local sleep_argv0="password store sleep on display $display_name"
 
@@ -192,7 +196,11 @@ clip() {
 		# so we axe it here:
 		qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
 
-		echo "$before" | $BASE64 -d | "${copy_cmd[@]}"
+		if [[ -n $USE_GPASTE ]]; then
+			gpaste-client delete-password $2
+		else
+			echo "$before" | $BASE64 -d | "${copy_cmd[@]}"
+		fi
 	) >/dev/null 2>&1 & disown
 	echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
 }
-- 
2.47.3



More information about the Password-Store mailing list