diff options
author | Ayush Agarwal <ayush@fastmail.in> | 2022-02-16 22:21:26 +0530 |
---|---|---|
committer | Ayush Agarwal <ayush@fastmail.in> | 2022-02-16 22:21:26 +0530 |
commit | 3239d30b10cf4162f23a58e78513818682c68638 (patch) | |
tree | cb19fa47d06b0856542098875b1e3831071b898e /tessen | |
parent | ad8559beb88fd7a7d8df9e7ec6a00b3963cd9a2f (diff) |
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
Diffstat (limited to 'tessen')
-rwxr-xr-x | tessen | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -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() { |