termux-packages/packages/pass/src-password-store.sh.patch

57 lines
2.6 KiB
Diff
Raw Normal View History

2016-03-22 00:11:52 +01:00
--- ../password-store-master/src/password-store.sh 2016-02-07 12:05:52.000000000 +0100
+++ ./src/password-store.sh 2016-03-07 21:29:27.667761280 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/data/data/com.termux/files/usr/bin/env bash
# Copyright (C) 2012 - 2014 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
@@ -12,7 +12,9 @@
which gpg2 &>/dev/null && GPG="gpg2"
[[ -n $GPG_AGENT_INFO || $GPG == "gpg2" ]] && GPG_OPTS+=( "--batch" "--use-agent" )
+TERMUXPREFIX=$PREFIX
PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
+
X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}"
CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}"
GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}"
@@ -133,13 +135,13 @@
# 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"
+ pgrep -f "^$sleep_argv0" | xargs kill 2>/dev/null && sleep 0.5
+ local before="$(termux-clipboard-get 2>/dev/null | base64)"
+ echo -n "$1" | termux-clipboard-set || die "Error: Could not copy data to the clipboard"
(
- ( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
- local now="$(xclip -o -selection "$X_SELECTION" | base64)"
- [[ $now != $(echo -n "$1" | base64) ]] && before="$now"
+ ( exec -a "$sleep_argv0" coreutils --coreutils-prog=sleep "$CLIP_TIME" )
+ local now="$(termux-clipboard-get | base64 )"
+ [[ $now != $(echo "$1" | 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,
@@ -150,7 +152,7 @@
# so we axe it here:
qdbus org.kde.klipper /klipper org.kde.klipper.klipper.clearClipboardHistory &>/dev/null
- echo "$before" | base64 -d | xclip -selection "$X_SELECTION"
+ echo "$before" | base64 -d| termux-clipboard-set
) 2>/dev/null & disown
echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
}
@@ -174,7 +176,8 @@
Are you sure you would like to continue?
_EOF
)"
- SECURE_TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/$template")"
+ echo "mktemp -d ${TMPDIR:-$TERMUXPREFIX/tmp}/$template"
+ SECURE_TMPDIR="$(mktemp -d "${TMPDIR:-$TERMUXPREFIX/tmp}/$template")"
shred_tmpfile() {
find "$SECURE_TMPDIR" -type f -exec $SHRED {} +
rm -rf "$SECURE_TMPDIR"