enpass-cli icon indicating copy to clipboard operation
enpass-cli copied to clipboard

Password should be cleared from clipboard after time threshold

Open i077 opened this issue 6 years ago • 5 comments

Similarly to how the desktop GUI handles it, when copying the password from the Enpass wallet, the CLI should clear the password from the clipboard after, say, 30 seconds so the password does not remain in the user's clipboard. I keep having to run xsel -bc after copying my passwords and it would be nice if the CLI could handle this. Maybe the process could fork to the background and set the clipboard to a space or null character then terminate.

i077 avatar Jun 27 '18 02:06 i077

Problem is this is very OS-specific. In lastpass-cli, I 'solved' it by specifying an alias for lpass copy | xsel -bc

hazcod avatar Jun 27 '18 05:06 hazcod

You mean the solution to clear the clipboard is OS-specific? Maybe you don't have to run a command specific to clearing the clipboard, just run copyToClip(" ") or copyToClip("\0") (if that works) after some time in the background.

i077 avatar Jun 27 '18 15:06 i077

That would involve forking into a new process that calls a timer and clears the clipboard. I welcome a PR. :-)

e.g. in pseudocode;

fork(copyToClip(copiedPass))

  def copyToClip(pass):
      copyToClipboard(pass)
      time.Sleep(minute)
      if clip.getClipboard() == pass:
        copyToClipboard("")

hazcod avatar Nov 29 '18 09:11 hazcod

Welp, I've moved on to pass, so I don't really use this software anymore :/

i077 avatar Dec 16 '18 15:12 i077

For linux/bash I'm achieving this in a wrapper function by trapping an xclip on SIGUSR1 and killing the process 30s later:

function enpasscli-copy-primary() {
  enpasscli -clipboardPrimary copy "$@" \
    && trap 'xclip -i < /dev/null' SIGUSR1 \
    && local current_pid=$BASHPID \
    && ( ( sleep 30; kill -SIGUSR1 $current_pid ) & ) > /dev/null 2>&1
}

adapt the xclip command if you prefer xsel or a different X selection.

msladek avatar Jul 16 '22 22:07 msladek