I have implemented a patch that makes password-store check for the presence of $SELECTION and use that instead of “selection” as the argument to xclip -selection.
On my system I use the primary clipboard for everything, and using the selection clipboard is much more difficult depending on the program.
>From 38a386aacbd628e48d6e98bc9441b5abd69bf008 Mon Sep 17 00:00:00 2001 From: Niklas Haas <[email protected]> Date: Wed, 5 Mar 2014 21:24:11 +0100 Subject: [PATCH] Allow selection to be overridden by $SELECTION With this, you can use SELECTION=primary when invoking pass to write the password to the primary clipboard instead of the selection clipboard, which may be more useful depending on the environment. --- man/pass.1 | 3 +++ src/password-store.sh | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/man/pass.1 b/man/pass.1 index efb5d9b..838a0b8 100644 --- a/man/pass.1 +++ b/man/pass.1 @@ -338,6 +338,9 @@ 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 SELECTION +Overrides the selection passed to \fBxclip\fP. +.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 2500253..aa0283e 100755 --- a/src/password-store.sh +++ b/src/password-store.sh @@ -81,15 +81,17 @@ yesno() { # BEGIN Platform definable # clip() { + [[ -n $SELECTION ]] || SELECTION="selection" + # This base64 business is a disgusting hack to deal with newline inconsistancies # 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 $SELECTION | base64)" + echo -n "$1" | xclip -selection $SELECTION ( sleep 45 - now="$(xclip -o -selection clipboard | base64)" + now="$(xclip -o -selection $SELECTION | base64)" if [[ $now != $(echo -n "$1" | base64) ]]; then before="$now" fi @@ -103,7 +105,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 ) & disown echo "Copied $2 to clipboard. Will clear in 45 seconds." } -- 1.8.5.3
0001-Allow-selection-to-be-overridden-by-SELECTION.patch.asc
Description: PGP message
_______________________________________________ Password-Store mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/password-store
