dnut / clipboard-sync

Synchronizes the clipboard across multiple X11 and wayland instances running on the same machine.
60 stars 10 forks source link

Does not work with citrix workspace #35

Open Kommynct opened 8 months ago

Kommynct commented 8 months ago

I use citrix workspace within sway, and the xwayland clipboard from that app has never synced, I was hoping this would fix the syncing between those things, but it appears to not do anything at all

the copied text is still available from citrix with xclip -o in an alacritty window (however if I run it within xterm, i get a different output, further complicating things)

Not sure what exactly is going on or what logs to send, might be an upstream issue with xwayland/sway

dnut commented 8 months ago

Thanks for the report. I'd like to clarify/confirm a few things about your setup before moving forward, to make sure I'm going in the right direction. I'll state some assumptions, and please correct anything I have wrong.

I did a quick google search about citrix workspace and it looks like a frontend/client application to access virtual machines. I'll use the word "pc" to refer to the computer where citrix workspace is installed. You use sway for your primary desktop environment on the pc. Within the virtual machine that you access using citrix, you also have linux running with some kind of graphical desktop environment.

You expect that the clipboard on the pc and the clipboard within the vm should be synchronized and have the same contents. This actually works to some extent, because xclip -o in alacritty running inside the vm is able to access the clipboard contents from the pc. But other applications, such as xterm, do not have access to the same clipboard. This is the behavior you see without running clipboard-sync. You tried running clipboard-sync, and it had no effect on the behavior.

questions:

Kommynct commented 8 months ago

I'm actually using sway on my physical machine, citrix has a windows virtual machine running within it.

When I run xclip -o inside of alacritty on my native sway environment after copying something from the windows virtual machine, it gives the correct output, however wl-paste says it is empty, meaning I cannot paste from the environment, unless I do a hacky workaround.

citrix workspace does support clipboard synchronization, and in fact, if I copy from a text editor running xwayland, and then copy from the virtual machine again, sometimes the clipboard does work properly, I sometimes have to swap between them repeatedly, and that is the only way I have been able to copy from citrix.

As the native sway is the only linux machine between the two, i ran clipboard sync on the native sway machine

Are you running any software within the virtual machine that integrates with citrix?

I don't really understand this question, there's a windows machine within a window that is the citrix workspace, there isn't any software except sway running citrix within it, connected to a windows virtual machine.

I hope this clarifies, although, I think this might be more of a sway/wlroots issue than your problem, I was just hoping that since xclip -o outputs the correct information that this tool would resolve the issue.

edit: I have found a hacky workaround, adding this to sway seems to completely fix the issue

bindsym --release Control+c exec swaymsg -t get_tree | jq '.. | select(.type?) | select(.focused==true) | .shell' | grep -Eq 'xwayland' && [xclip -o | wl-copy]

further edit: i've found situations where this gets completely ignored, so, it's not a real solution, I currently am having xclip -o output something different from wl-paste even though i've added this command to my bindsyms, UGH.

Kommynct commented 8 months ago

I've made a post here for the sway devs https://github.com/swaywm/sway/issues/7958

dnut commented 8 months ago

Sounds like my initial interpretation was pretty wrong.

In our assessment of clipboard-sync, I think we can ignore citrix workspace (for a moment) and look at the fact that you have two separate clipboards on your linux system with different contents. This is exactly the kind of thing that clipboard-sync is intended to reconcile.

It may be true that citrix or sway could be designed or implemented in a way that prevents this discrepancy from occurring in the first place. I'm not sure if those projects would consider this to be in scope because it means they would need to deal with multiple clipboards. Regardless, I would like clipboard-sync to be able to step in for whatever scenario might trigger a discrepancy like this and synchronize the clipboards.

I'm labeling this as a bug for now because I would have expected clipboard-sync to handle this. I will attempt to reproduce it. My current job has me busy using a macbook, so I'm not using a linux desktop much any more. I'm not sure when I'll get a chance to work on this, but it's high on this project's priority list.

Kommynct commented 8 months ago

I'm very happy to hear that, thank you so much!

Let me know if there's anything I can do to help!

Kommynct commented 8 months ago

I have discovered something new about the intricacies of this, I decided to try running a VM with i3, thinking that if I have a vm running x.org as an intermediary between citrix and the xwayland clipboard, that might resolve it... what i've discovered is that citrix actually doesn't even write to the clipboard until focus is lost, and on wayland, citrix doesn't have a way of knowing that focus was lost due to the inherent secure nature of the protocol, and that's why i'm able to make it work by rapidly switching between citrix and zim, if I go to my i3 vm, copy something, and switch workspaces back and forth, it works 100% of the time, if I don't switch workspaces back and forth, nothing is copied to the clipboard

This also explains why running xclip -o | wl-copy works from alacritty, because i've moved the focus away from citrix and running the xclip -o tells the x11 server that the focus has been moved, whereas running it as a keybind doesn't do that.

Jesus christ.