[pass] [PATCH 2/2] clip: add GPaste support
Marc-Antoine Perennou
Marc-Antoine at Perennou.com
Thu Feb 5 21:35:45 CET 2015
GPaste is a clipboard which now supports password natively without writing
them to its history file and displaying a given name to identify them.
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine at Perennou.com>
---
src/password-store.sh | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/password-store.sh b/src/password-store.sh
index d10b7c2..4d6a51a 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -131,6 +131,14 @@ clip_sleep() {
( exec -a "$1" sleep "$CLIP_TIME" )
}
+clip_gpaste() {
+ gpaste add-password "$3" "$2" || die "Error: Could not copy data to the clipboard"
+ (
+ clip_sleep "$1"
+ gpaste delete-password "$3"
+ ) 2>/dev/null & disown
+}
+
clip_xclip() {
# This base64 business is because bash cannot store binary data in a shell
# variable. Specifically, it cannot store nulls nor (non-trivally) store
@@ -158,7 +166,13 @@ clip_xclip() {
clip() {
local sleep_argv0="password store sleep on display $DISPLAY"
pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
- clip_xclip "$sleep_argv0" "$@"
+ local gpaste=0
+ gpaste help | grep -q password && gpaste=1
+ if [[ $gpaste -eq 1 ]]; then
+ clip_gpaste "$sleep_argv0" "$@"
+ else
+ clip_xclip "$sleep_argv0" "$@"
+ fi
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
--
2.2.2
More information about the Password-Store
mailing list