savedra1 / clipse

Configurable TUI clipboard manager for Unix
MIT License
217 stars 8 forks source link

Not copying to buffer when using clipse from a hotkey (in floating term) #45

Open Lethaquell opened 2 months ago

Lethaquell commented 2 months ago

Hello! I'm using Archcraft with bspwm.

I'm running listening from bspwmrc config as exec clipse -listen & Then I have a sxhkdrc config for my keybinds, I've configured clipse to open in floating alacritty terminal as:

ctrl + super + v
  bspterm --float -e clipse

bspterm is basically an Alacritty term executing from bash script for managing float/fullscreen behavior:

image

The problem is:

  1. I'm copying stuff from browser/term -- it's getting to clipse history
  2. I'm opening clipse in floating mode using my keybind -- it opens and I can see history
  3. I'm pressing enter to copy any entry from clipse -- I can't paste it, buffer is empty
  4. But If I'll open clipse just im my regular term and do the same (copy any entry) everything is OK and I can paste things from buffer

Am I doing something wrong?

Quick UPD:

savedra1 commented 2 months ago

Hey @Lethaquell :wave: thanks for raising this.

This is a new one! Which system clipboard utility are you using here? eg wl-clipboard, xsel, xclip etc. It's possible you're using something that only keeps clipboard history within a certain context. It may be worth testing this with something like:

alacritty -e wl-copy test
alacritty -e sh -c 'echo test | wl-copy' 

The recommended dependencies for this are wl-clipboard for wayland and xclip for xorg.

Could be worth checking what happens when you run the following also:

alacritty -e clipse -c test
alacritty -e sh -c 'echo test | clipse -c'

You could also try amending your script to add a short sleep after clipse has executed, or try -e sh -c clipse to see if that makes a difference.

I might look into adding an arg that will output what's been copied to allow a piping command like alacritty -e sh -c 'clipse -out | clipse -c' if that is found to be an issue with the system environment (Archcraft), though hopefully it's more simple than that.

Lethaquell commented 2 months ago

Hello @savedra1! Thanks for reaching me back, appreciate it.

I'm using xclip cause bspwm works on xorg. I also have wl-clipboard installed, but for other WM's on Wayland. xsel isn't installed.

I've tried some tests eg:

alacritty -e sh -c "echo test | xclip -selection clipboard"
alacritty -e sh -c 'echo test | clipse -c'
alacritty -e clipse -c test

I've also tried to add sleep before executing clipse itself, but for now nothing is working for me.

To be clear, when I'm executing echo test | xclip -selection clipboard from xfce4-terminal it works just fine even after closing the terminal itself.

If there is anything I can also try -- I'll be grateful for any advises. I'll also investigate on problem furthermore on my spare time.

P.S. I might be entirely wrong, but can it be somehow related with OSC52 functionality/compatibility within alacritty?

savedra1 commented 2 months ago

@Lethaquell I see :thinking:

You could be on to something there with osc52, found this in the Alacritty docs:

This section documents the [terminal] table of the configuration file.

osc52 = "Disabled" | "OnlyCopy" | "OnlyPaste" | "CopyPaste"

Controls the ability to write to the system clipboard with the OSC 52 escape sequence. While this escape sequence is useful to copy contents from the remote server, allowing any application to read from the clipboard can be easily abused while not providing significant benefits over explicitly pasting text.

Default: "OnlyCopy"

you could try setting this to CopyPaste in the [terminal] section of your config?

Lethaquell commented 2 months ago

@savedra1 it's on CopyPaste right now, I've tested these particular settings yesterday. Also tried Disabled and CopyPaste. I can confirm that my bspterm uses this config, not any other.

savedra1 commented 2 months ago

Thanks for letting me know @Lethaquell

Seems like the connection to the X clipboard server is terminating along with the terminal session when alacritty is used. I'm wondering if there's a way to get this to persist to the main session clipboard by attaching an extra command to what you're currently using.

The copy mechanism used by clipse for X environments is xclip -in -selection clipboard but it's posible the -in arg is restricting it to the current terminal sesison Maybe something like this could help:

alacritty -e clipse | clipboard_contents=$(xclip -selection clipboard -o) && echo '$clipboard_contents' | xclip -selection clipboard

OR

alacritty -e "clipse; clipboard_contents=$(xclip -selection clipboard -o) && echo '$clipboard_contents' | xclip -selection clipboard"

Not sure if that will help though as I'm unable to test an X environment atm.