bugaevc / wl-clipboard

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

wl-paste -p conflicts with wl-paste #94

Closed AdrienLemaire closed 4 years ago

AdrienLemaire commented 4 years ago

versions:

sway binding:

exec wl-paste -t text --watch clipman store
exec wl-paste -p -t text --watch clipman store --histpath="~/.local/share/clipman-primary.json"

Current behavior

Selecting any text will have it copied in both ~/.local/share/clipman.json and ~/.local/share/clipman-primary.json

$ ] ➜ diff ~/.local/share/clipman* && echo "files are identical"
files are identical

It's also very hard to using copy-pasting with wl-paste -p --watch, because Ctrl-v will paste the last selected text (not necessarily the text I wanted to copy).

Expected behavior

The first wl-paste --watch process should only store CLIPBOARD text (copied with Ctrl-C), not all text selections.

Note

clipman's readme suggest to add wl-paste -p --watch : https://github.com/yory8/clipman#usage

When only using

exec wl-paste -t text --watch clipman store
# exec wl-paste -p -t text --watch clipman store --histpath="~/.local/share/clipman-primary.json"

Text is only copied with Ctrl-c. That's fine, but I'm looking for a way to speed up pasting different recorded values (right now, I need to Ctrl-c my 2+ values, then I need to do clipman pick -t bemenu each time I want to paste the previous value, which is quite counter-productive. I wish I could do something like $mod-v-X with X being the index of the item in the clipman json array.

AdrienLemaire commented 4 years ago

While the bug persists, I could find a different solution for the feature I was looking for

exec wl-paste -t text --watch clipman store
exec clipman restore
bindsym Ctrl+h exec clipman pick -t bemenu -T'-b -i -n --nb #282a2e --nf #de935f --hb #373b41 --tb #373b41 --hf #f0c674 --tf #f0c674'
bindsym $mod+$alt+1 exec wl-copy $(jq -r ".[-1]" ~/.local/share/clipman.json) && /usr/bin/env bash -c 'ydotool key ctrl+shift+v'
bindsym $mod+$alt+2 exec wl-copy $(jq -r ".[-2]" ~/.local/share/clipman.json) && /usr/bin/env bash -c 'ydotool key ctrl+shift+v'
bindsym $mod+$alt+3 exec wl-copy $(jq -r ".[-3]" ~/.local/share/clipman.json) && /usr/bin/env bash -c 'ydotool key ctrl+shift+v'
bindsym $mod+$alt+4 exec wl-copy $(jq -r ".[-4]" ~/.local/share/clipman.json) && /usr/bin/env bash -c 'ydotool key ctrl+shift+v'
bindsym $mod+$alt+5 exec wl-copy $(jq -r ".[-5]" ~/.local/share/clipman.json) && /usr/bin/env bash -c 'ydotool key ctrl+shift+v'

Now, I can press Mod+Alt+2 to print the second to last command (but I need to keep in mind that everytime, it'll update my clipman.json values order.

bugaevc commented 4 years ago

Can you please start by trying to reproduce this without clipman? If you just run, say

$ wl-paste -w bash -c 'echo -n clipboard: && cat && echo'

in one tab, and

$ wl-paste -pw bash -c 'echo -n primary: && cat && echo'

Does it work as expected, or do they "conflict"?

AdrienLemaire commented 4 years ago

@bugaevc they don't :sweat_smile: Thanks for the reply, I'll recreate the issue in clipman's repo :bow: