From 3239d30b10cf4162f23a58e78513818682c68638 Mon Sep 17 00:00:00 2001 From: Ayush Agarwal Date: Wed, 16 Feb 2022 22:21:26 +0530 Subject: feat: add support for gopass when copying data when using pass, use the clipboard timeout value specified by PASSWORD_STORE_CLIP_TIME and if this isn't specified, fallback to 15 seconds. when using gopass, use the clipboard timeout value as specified in the `cliptimeout` key in gopass config --- tessen | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'tessen') diff --git a/tessen b/tessen index 1f7a1bf..66eecfc 100755 --- a/tessen +++ b/tessen @@ -457,15 +457,38 @@ auto_type() { # POTENTIAL IMPROVEMENT: We could restore the clipboard as it was before pass # was used. This is done by default by pass. wld_copy() { + local tsn_cliptime + + if [[ "$pass_backend" == "pass" ]]; then + tsn_cliptime="${PASSWORD_STORE_CLIP_TIME:-15}" + if ! are_digits "$tsn_cliptime"; then + printf "%s\n" "invalid clipboard timeout value in PASSWORD_STORE_CLIP_TIME" >&2 + return 1 + fi + elif [[ "$pass_backend" == "gopass" ]]; then + tsn_cliptime="$(gopass config cliptimeout)" + tsn_cliptime="${tsn_cliptime##*: }" + if ! are_digits "$tsn_cliptime"; then + printf "%s\n" "invalid clipboard timeout value in cliptimeout" >&2 + return 1 + fi + fi + # it would've been better to use, or at least provide an option, to paste + # only once using `wl-copy -o` but web browsers don't work well with this + # feature + # https://github.com/bugaevc/wl-clipboard/issues/107 printf "%s" "$1" | wl-copy if is_installed notify-send; then - notify-send -t $((tsn_cliptime * 1000)) "Copied username to clipboard. Will clear in $tsn_cliptime seconds." + notify-send -t $((tsn_cliptime * 1000)) \ + "Copied username to clipboard. Will clear in $tsn_cliptime seconds." fi { sleep "$tsn_cliptime" || exit 1 wl-copy --clear } > /dev/null 2>&1 & - unset -v tsn_passfile tsn_username tsn_password tsn_passdata chosen_key + + unset -v tsn_cliptime + unset -v tsn_passfile tsn_passdata tsn_username tsn_password chosen_key } print_help() { -- cgit v1.2.3