[pass] [PATCH 1/2] Configurable X selection for xclip
Matthieu Weber
mweber at free.fr
Mon Aug 5 20:35:39 CEST 2013
---
man/pass.1 | 5 +++++
src/password-store.sh | 11 ++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/man/pass.1 b/man/pass.1
index efb5d9b..fc302c6 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -338,6 +338,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_X_SELECTION
+Overrides the default X selection (X Window only). The default value
+("clipboard") allows pasting with CTRL-V, while "primary" allows pasting with
+a middle-click.
+.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 e080627..2b8aba8 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -9,6 +9,7 @@ PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
ID="$PREFIX/.gpg-id"
GIT_DIR="${PASSWORD_STORE_GIT:-$PREFIX}/.git"
GPG_OPTS="--quiet --yes --batch"
+X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}"
export GIT_DIR
export GIT_WORK_TREE="${PASSWORD_STORE_GIT:-$PREFIX}"
@@ -85,11 +86,11 @@ clip() {
# in shell. There must be a better way to deal with this, but because I'm a dolt,
# we're going with this for now.
- before="$(xclip -o -selection clipboard | base64)"
- echo -n "$1" | xclip -selection clipboard
+ before="$(xclip -o -selection $X_SELECTION | base64)"
+ echo -n "$1" | xclip -selection $X_SELECTION
(
sleep 45
- now="$(xclip -o -selection clipboard | base64)"
+ now="$(xclip -o -selection $X_SELECTION | base64)"
if [[ $now != $(echo -n "$1" | base64) ]]; then
before="$now"
fi
@@ -103,9 +104,9 @@ 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 $X_SELECTION
) & disown
- echo "Copied $2 to clipboard. Will clear in 45 seconds."
+ echo "Copied $2 to $X_SELECTION. Will clear in 45 seconds."
}
tmpdir() {
if [[ -d /dev/shm && -w /dev/shm && -x /dev/shm ]]; then
--
1.7.2.5
More information about the Password-Store
mailing list