Signed-off-by: Marc-Antoine Perennou <[email protected]>
---
 src/password-store.sh | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 6313384..d10b7c2 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -127,18 +127,20 @@ check_sneaky_paths() {
 # BEGIN platform definable
 #
 
-clip() {
+clip_sleep() {
+       ( exec -a "$1" sleep "$CLIP_TIME" )
+}
+
+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
        # trailing new lines.
-       local sleep_argv0="password store sleep on display $DISPLAY"
-       pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
        local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | 
base64)"
-       echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not 
copy data to the clipboard"
+       echo -n "$2" | xclip -selection "$X_SELECTION" || die "Error: Could not 
copy data to the clipboard"
        (
-               ( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
+               clip_sleep "$1"
                local now="$(xclip -o -selection "$X_SELECTION" | base64)"
-               [[ $now != $(echo -n "$1" | base64) ]] && before="$now"
+               [[ $now != $(echo -n "$2" | base64) ]] && before="$now"
 
                # It might be nice to programatically check to see if klipper 
exists,
                # as well as checking for other common clipboard managers. But 
for now,
@@ -151,8 +153,15 @@ clip() {
 
                echo "$before" | base64 -d | xclip -selection "$X_SELECTION"
        ) 2>/dev/null & disown
+}
+
+clip() {
+       local sleep_argv0="password store sleep on display $DISPLAY"
+       pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+       clip_xclip "$sleep_argv0" "$@"
        echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
 }
+
 tmpdir() {
        [[ -n $SECURE_TMPDIR ]] && return
        local warn=1
-- 
2.2.2

_______________________________________________
Password-Store mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/password-store

Reply via email to