1
0
mirror of https://github.com/termux/termux-packages synced 2024-06-19 01:27:07 +00:00
termux-packages/packages/pass/src-password-store.sh.patch
glow 5f5b2dcf26
pass: termux-clipboard-set even if DISPLAY is set (#7193)
With the current patch, pass will try to use `xclip` when `$DISPLAY` is
set. Termux (most of the time) doesn't have `xclip` even if `$DISPLAY`
is set, so this change will check for `xclip` specifically (and
`wl-copy`/`wl-paste` in case of `$WAYLAND_DISPLAY`).

So, if a user has `xclip` and `$DISPLAY` set, it will still use `xclip`,
otherwise it will use `termux-clipboard-set`.
2021-07-26 12:52:25 +03:00

47 lines
1.6 KiB
Diff

--- password-store-1.7.4/src/password-store.sh 2021-06-11 18:49:06.000000000 +0200
+++ password-store-1.7.4.mod/src/password-store.sh 2021-07-26 10:10:09.076790995 +0200
@@ -155,7 +155,7 @@
#
clip() {
- if [[ -n $WAYLAND_DISPLAY ]]; then
+ if [[ -n $WAYLAND_DISPLAY ]] && hash wl-copy 2>/dev/null && hash wl-paste 2>/dev/null; then
local copy_cmd=( wl-copy )
local paste_cmd=( wl-paste -n )
if [[ $X_SELECTION == primary ]]; then
@@ -163,12 +163,14 @@
paste_cmd+=( --primary )
fi
local display_name="$WAYLAND_DISPLAY"
- elif [[ -n $DISPLAY ]]; then
+ elif [[ -n $DISPLAY ]] && hash xclip 2>/dev/null; then
local copy_cmd=( xclip -selection "$X_SELECTION" )
local paste_cmd=( xclip -o -selection "$X_SELECTION" )
local display_name="$DISPLAY"
else
- die "Error: No X11 or Wayland display detected"
+ local copy_cmd=( termux-clipboard-set )
+ local paste_cmd=( termux-clipboard-get )
+ local display_name="termux"
fi
local sleep_argv0="password store sleep on display $display_name"
@@ -225,7 +227,7 @@
}
trap remove_tmpfile EXIT
else
- [[ $warn -eq 1 ]] && yesno "$(cat <<-_EOF
+ [[ $(uname -o) == "Android" ]] || [[ $warn -eq 1 ]] && yesno "$(cat <<-_EOF
Your system does not have /dev/shm, which means that it may
be difficult to entirely erase the temporary non-encrypted
password file after editing.
@@ -233,7 +235,7 @@
Are you sure you would like to continue?
_EOF
)"
- SECURE_TMPDIR="$(mktemp -d "${TMPDIR:-/tmp}/$template")"
+ SECURE_TMPDIR="$(mktemp -d "${TMPDIR:-@TERMUX_PREFIX@/tmp}/$template")"
shred_tmpfile() {
find "$SECURE_TMPDIR" -type f -exec $SHRED {} +
rm -rf "$SECURE_TMPDIR"