aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/password-store.sh
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-03-20 00:45:52 -0600
committerJason A. Donenfeld <Jason@zx2c4.com>2014-03-20 00:45:52 -0600
commit2c9c36e3ca8eab1a3f9056d18619f80cedf3781d (patch)
treef8ad112b95465960bf320986b681dfa0403d0232 /src/password-store.sh
parentStyle. (diff)
downloadpassword-store-2c9c36e3ca8eab1a3f9056d18619f80cedf3781d.tar.xz
password-store-2c9c36e3ca8eab1a3f9056d18619f80cedf3781d.zip
clip: don't race between pass instances in restore
We now make sure a previous pass clip restore finishes immediately when copying another password to the clipboard. This is currently only implemented on Linux.
Diffstat (limited to 'src/password-store.sh')
-rwxr-xr-xsrc/password-store.sh6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index 6fa32c1..f7ad52b 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -113,10 +113,12 @@ 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.
+ 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
(
- sleep 45
+ ( exec -a "$sleep_argv0" sleep 45 )
now="$(xclip -o -selection clipboard | base64)"
[[ $now != $(echo -n "$1" | base64) ]] && before="$now"
@@ -130,7 +132,7 @@ clip() {
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
echo "$before" | base64 -d | xclip -selection clipboard
- ) & disown
+ ) 2>/dev/null & disown
echo "Copied $2 to clipboard. Will clear in 45 seconds."
}
tmpdir() {