[PATCH] Add support for Windows clipboard (WSL)

Douglas Silva doug.hs at proton.me
Sun May 14 06:05:58 UTC 2023


Windows 11 is now exposing your display to WSL. This means xclip and wl-clipboard will no longer fail with an error.

pass will attempt to use wl-clipboard, because the variable $WAYLAND_DISPLAY is now set ("wayland-0").

This Wayland display mirrors your host [Windows] display. I've tested it and the clip function works, including the cleanup after 45 seconds.






------- Original Message -------
Em sábado, 15 de outubro de 2022 às 8:59 PM, Douglas Silva <doug.hs at proton.me> escreveu:


> This makes the -c (copy to clipboard) option work on WSL, by using the clip.exe command if it's available. I picked $WSL_DISTRO_NAME to test for it.
> 
> Note that I didn't set "paste_cmd" or "display_name". I couldn't find any paste command for Windows, and I don't understand what they're used for.
> 
> ---
> src/password-store.sh | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/password-store.sh b/src/password-store.sh
> index 22e818f..7f64b68 100755
> --- a/src/password-store.sh
> +++ b/src/password-store.sh
> @@ -155,7 +155,9 @@ check_sneaky_paths() {
> #
> 
> clip() {
> - if [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
> 
> + if [[ -n $WSL_DISTRO_NAME ]] && command -v clip.exe &> /dev/null; then
> 
> + local copy_cmd=( clip.exe )
> + elif [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
> 
> local copy_cmd=( wl-copy )
> local paste_cmd=( wl-paste -n )
> if [[ $X_SELECTION == primary ]]; then
> --
> 2.34.1


More information about the Password-Store mailing list