bugaevc / wl-clipboard

Command-line copy/paste utilities for Wayland
GNU General Public License v3.0
1.62k stars 59 forks source link

wl-copy not saving contents in this script? #121

Closed rieje closed 3 years ago

rieje commented 3 years ago

Most likely not a bug as the script is so simple--it lets the user edit the contents of the clipboard by first saving it to a file, opening it with a text editor, saving that contents to the file, then finally copying back to clipboard.

The last line: "sleep .02; ${EDITOR:-nvim} $file; cat $file | wl-copy" opens nvim with clipboard contents. When I save the file, nvim and alacritty closes. Alacritty closes when the command exits, which is 'bash -c' in this case, IIUC, as expected. However, the clipboard is cleared instead of the saved contents copied to the clipboard.

Replacing the last line with: "sleep .02; ${EDITOR:-nvim} $file && { cat $file | wl-copy ;} && sleep 3" This will keep the terminal open for 3 seconds and the clipboard gets updated (i.e. it works); however, when terminal closes, clipboard contents is cleared. wl-copy -f also correctly updates the clipboard, but it holds up the terminal (I want the terminal closed--I only need it for nvim to edit the clipboard).

But what I'm confused is if I open a terminal and run echo "abc" | wl-copy, the contents of the clipboard ("abc") is preserved even if I close the terminal, so I don't think I need an actual clipboard manager.

bugaevc commented 3 years ago

Hello!

Does the version of wl-clipboard you're using include commit https://github.com/bugaevc/wl-clipboard/commit/d2c32f2b4d469f53070e8c4052dea6f412de3916?

Also, you have a useless use of cat in there, cat $file | wl-copy should be wl-copy < "$file".

rieje commented 3 years ago

I was using the latest version. Just installed the one from master, and it works as expected. Thanks for that and the cat suggestion.