From 2e1520beddcea65cb1857a50e9ec5c91621a96d1 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 20 Mar 2014 01:57:46 -0600 Subject: Allow selection to be overriden by $SELECTION Some users want to use a different clipboard for pass. Suggested-by: nand --- man/pass.1 | 5 +++++ src/password-store.sh | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/man/pass.1 b/man/pass.1 index 2b3e5e3..896ec4f 100644 --- a/man/pass.1 +++ b/man/pass.1 @@ -349,6 +349,11 @@ Overrides the default root of the git repository, which is helpful if \fIPASSWORD_STORE_DIR\fP is temporarily set to a sub-directory of the default password store. .TP +.I PASSWORD_STORE_SELECTION +Overrides the selection passed to \fBxclip\fP, by default \fIclipboard\fP. See +.BR xclip (1) +for more info. +.TP .I EDITOR The location of the text editor used by \fBedit\fP. diff --git a/src/password-store.sh b/src/password-store.sh index a5d3374..4f2239f 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -7,6 +7,7 @@ umask 077 GPG_OPTS="--quiet --yes --batch --compress-algo=none" PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}" +SELECTION="${PASSWORD_STORE_SELECTION:-clipboard}" export GIT_DIR="${PASSWORD_STORE_GIT:-$PREFIX}/.git" export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}" @@ -116,11 +117,11 @@ clip() { sleep_argv0="password store sleep on display $DISPLAY" kill -9 $(grep -l -r --include="cmdline" "^$sleep_argv0" /proc/ 2>/dev/null | sed -n 's:/proc/\([0-9]\+\)/.*:\1:p' | sort | uniq) 2>/dev/null && sleep 0.1 - before="$(xclip -o -selection clipboard | base64)" - echo -n "$1" | xclip -selection clipboard + before="$(xclip -o -selection "$SELECTION" | base64)" + echo -n "$1" | xclip -selection "$SELECTION" ( ( exec -a "$sleep_argv0" sleep 45 ) - now="$(xclip -o -selection clipboard | base64)" + now="$(xclip -o -selection "$SELECTION" | base64)" [[ $now != $(echo -n "$1" | base64) ]] && before="$now" # It might be nice to programatically check to see if klipper exists, @@ -132,7 +133,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 clipboard + echo "$before" | base64 -d | xclip -selection "$SELECTION" ) 2>/dev/null & disown echo "Copied $2 to clipboard. Will clear in 45 seconds." } -- cgit v1.2.3