Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy from far2l to other apps don't works on Wayland Labwc (Raspberry Pi Bookworm) [far2l v2.6.4-2024-12-29-9fb21334-beta] #2608

Open
qrp73 opened this issue Dec 31, 2024 · 35 comments

Comments

@qrp73
Copy link

qrp73 commented Dec 31, 2024

I'm using Raspberry Pi Bookworm with Wayland Labwc desktop.
Just cloned and compiled latest version of far2l v2.6.4-2024-12-29-9fb21334-beta.

When I start far2l --tty from desktop with lxterminal, it can paste clipboard text from other apps (with Shift+Insert). But cannot copy text from far2l to other apps (with Ctrl+Insert).

When I do Ctrl+Insert in far2l, wl-paste shows empty, even if before it contained some text (far2l just clears clipboard content).

Here is wl-paste output, the first one is before copy from far2l, the second one is after copy text "Съешь ещё этих мягких французских булок, да выпей же чаю." from far2l. With ASCII text I get the same issue.

$ wl-paste
asd
$ wl-paste

$ wl-paste -l
text/plain;charset=utf-8
UTF8_STRING
COMPOUND_TEXT
TEXT
text/plain
STRING
SAVE_TARGETS

If it matters, my terminal shortcuts are configured to use Shift+Insert for Paste and Ctrl+Insert for Copy.

Also, when I try to insert a file from the panel into the command line using Ctrl+Enter in far2l running in desktop mode, it doesn't work. Instead, it just opens the file in an external editor for text files or executes it for bash scripts. However, when I run far2l from a virtual terminal, Ctrl+Enter works as expected.

When I run it in GUI mode with far2l --wayland, the clipboard copy/paste works ok in both directions and Ctrl+Enter also works ok.

Update: some new finding. When I start far2l --tty from lxterminal I cannot copy text from far2l to other app, but can copy text from other apps to far2l. But when I start far2l --tty from gnome-terminal it works the other way around - I can copy text from far2l to other apps, but cannot copy text from other apps to far2l.

Update2: additional findings. When running far2l remotely over SSH from a virtual terminal (where copy/paste works during local use), copying in the editor (from far2l to far2l) doesn't work for some reason. It was also discovered that text selection in the editor doesn't display properly (the text isn't inverted). However, when connecting over SSH from far2l, text selection in the editor works, but attempting to copy text causes the application to freeze.

@akruphi
Copy link
Contributor

akruphi commented Dec 31, 2024

Note: lxterminal not fully compatible now with far2l (lxterminal based on VTE, where not all keyboard shortcuts transferred to inside application). List of compatible terminals see in https://github.com/elfmz/far2l/#terminals and in Russian wiki

When I start far2l --tty from desktop with lxterminal, it can paste clipboard text from other apps (with Shift+Insert). But cannot copy text from far2l to other apps (with Ctrl+Insert).

far2l try access to clipboard by Ctrl-C or Ctrl-Ins to copy and Ctrl-V or Shift-Ins to paste. Some of keys may be used in terminal emulator and not transferred to inside far2l (usually in such case terminal by Shift-Ins make bracketed paste - terminal itself get data from clipboard and send it to inside application as characters). far2l directly inside terminal could not access to clipboard: see Note about OSC52 after table in https://github.com/elfmz/far2l/#ui-backends

when connecting over SSH from far2l, text selection in the editor works, but attempting to copy text causes the application to freeze.

What far2l freezes: local far2l or remote far2l?

Please give additional detail: screenshots far:about (type inside far2l command-line and Enter) from host far2l and remote far2l. If local far2l GUI work with clipboard without problem and remote far2l show Backend: TTY|F but clipboard not work properly it is real far2l bug.

@unxed
Copy link
Contributor

unxed commented Dec 31, 2024

Is OSC52 turned on in far2l?

@qrp73
Copy link
Author

qrp73 commented Dec 31, 2024

What far2l freezes: local far2l or remote far2l?

it freezes local far2l, it will require to force kill the process, because no way to exit from that state.

Is OSC52 turned on in far2l?

I tried it with default settings, on both machines it was started with far2l --tty. Didn't seen this setting, needs to test it. If it matters, the remote machine don't have any desktop installed, just console prompt. Both machines running on Raspi OS Bookworm aarch64. Local one has running Wayland Labwc desktop, but I run far2l from a virtual terminal.

Where is the OSC52 option? I don't see it in CMake, in far2l --help, or in the far2l settings. I see it in the source code but am not sure how to enable it, according to the text in source code it should be in Menu->Options->Interface Settings->Use OSC52, but I don't see this option on this setting window:
20241231_21h02m49s_grim-r

@akruphi
Copy link
Contributor

akruphi commented Dec 31, 2024

@qrp73 please show screenshots of pseudocommand far:about from host far2l and from remote far2l.
In usual way in host far2l must be Backend: GUI and in remote far2l must be Backend: TTY|F. In this situation OSC52 not need (OSC52 checkbox shown in Interface settings only if other more preferable access to clipboard not available).

@qrp73
Copy link
Author

qrp73 commented Jan 1, 2025

It appears that GUI version also leads to freeze when I trying to do copy operation on remote far2l. And it appears that both remote and local far2l are frozen.

Here is far:about from local machine:
20250101_03h16m19s_grim

And here is far:about from remote machine running within ssh session from far2l running on local machine:
20250101_03h17m27s_grim

After a long delay I get this message, but the local process still not respond on any input and is unable to process close button click:
20250101_03h19m29s_grim

Remote machine callstack when this freeze happens:
20250101_03h27m13s_grim

Local machine callstack when this freeze happens:
20250101_03h53m23s_grim
20250101_03h57m35s_grim

@qrp73
Copy link
Author

qrp73 commented Jan 1, 2025

The above results are taken with no clipboard manager. I also have a simple clipboard helper/manager based on wl-clipboard and I get the same issue with it. But I notice interesting thing. When I run local far2l and trying to copy text from it's text editor, the first attempt is ok, but the second fails and it leads to a frozen clipman2 process (my clipboard helper). Debugger shows that it is frozen on waiting data from stdin pipe. I didn't catch such behavior with usual text editors. I added 200 ms timeout on read operation and it solve the issue. But it seems something is going strange on copy/paste operations in far2l.

I suspect this freeze may have similar root of cause with infinite wait for read operation.

@akruphi
Copy link
Contributor

akruphi commented Jan 1, 2025

Here is far:about from local machine:

And here is far:about from remote machine running within ssh session from far2l running on local machine:

Important that you desktop local computer also based on Raspberry Pi with Wayland. If it possible please give info about situations:

  • only far2l-GUI on Raspberry Pi with Wayland: clipboard OK/BAD ?
  • far2l-GUI on regular Linux and inside ssh to far2l on Raspberry Pi: clipboard OK/BAD ?

@qrp73
Copy link
Author

qrp73 commented Jan 1, 2025

* only **far2l-GUI on Raspberry Pi with Wayland**: clipboard OK/BAD ?

No, far2l-TTY (from virtual terminal which can be accessed with Alt+Ctrl+F1) on Raspberry Pi with Wayland also fails

* **far2l-GUI on regular Linux** and inside **ssh to far2l on Raspberry Pi**: clipboard OK/BAD ?

I will test it later

@spnethw
Copy link
Contributor

spnethw commented Jan 15, 2025

Update2: additional findings. When running far2l remotely over SSH from a virtual terminal (where copy/paste works during local use), copying in the editor (from far2l to far2l) doesn't work for some reason. It was also discovered that text selection in the editor doesn't display properly (the text isn't inverted). However, when connecting over SSH from far2l, text selection in the editor works, but attempting to copy text causes the application to freeze.

This bug is also reproducible on X11.
The local far2l hangs (it doesn't matter if it's the TTY or GUI version), while the remote one continues to function normally.

@unxed
Copy link
Contributor

unxed commented Jan 15, 2025

Is where any way to reproduce it on my Cinnamon desktop?

@spnethw
Copy link
Contributor

spnethw commented Jan 16, 2025

Update2: additional findings. When running far2l remotely over SSH from a virtual terminal (where copy/paste works during local use), copying in the editor (from far2l to far2l) doesn't work for some reason. It was also discovered that text selection in the editor doesn't display properly (the text isn't inverted). However, when connecting over SSH from far2l, text selection in the editor works, but attempting to copy text causes the application to freeze.

This bug is also reproducible on X11. The local far2l hangs (it doesn't matter if it's the TTY or GUI version), while the remote one continues to function normally.

The freezes began to occur after this commit: d1fed9a
@elfmz

@qrp73
Copy link
Author

qrp73 commented Jan 16, 2025

I also noticed that sometimes far2l may freeze when I press Enter to open a folder. Sometimes it can delay for 20-30 seconds and become unresponsive to keyboard input, but then it may unexpectedly unfreeze. Retrying the same action (pressing Enter on the same folder) usually works without any freeze, it happens with usual user folder, so it don't related to some special folder issues.

This is a very annoying issue because it tends to happen unexpectedly.

I am not sure if this is related to the copy/paste issue, but the freeze behavior appears similar.

@unxed
Copy link
Contributor

unxed commented Jan 16, 2025

Workaround: after switching windows with ctrl+tab I managed to see dialog, same method works for selecting item.

unxed added a commit to unxed/far2l that referenced this issue Jan 16, 2025
@unxed unxed mentioned this issue Jan 16, 2025
@unxed
Copy link
Contributor

unxed commented Jan 16, 2025

Solved the problem at least partially (no more freezing). There is a bug left: if you press ESC, the background is shown from host-far2l, this is wrong. But you can use it, everything works.

Test it please!

#2636

@qrp73
Copy link
Author

qrp73 commented Jan 17, 2025

@unxed just tried to apply your patch for ConsoleOutput.cpp, and then tested remote far2l tty started from local far2l wx. And at a glance it works good, no freeze now, copy/paste works as expected.

Also tested remote far2l tty started from local far2l tty running on virtual terminal, also works ok with no freeze.

But for some unknown reason when I run local far2l --tty in wayland labwc desktop lxterminal, copy operation don't works. When I press Ctrl+Insert it just do nothing and clear current clipboard content. There is no freeze, just copy operation don't works (the same as before patch). While paste operation with Shift+Insert works ok. So, when I open far2l editor, I can paste text from other x11/wayland apps, but unable to copy/paste text within far2l editor. Could you please check it?

At the same time when I run far2l --tty from a virtual terminal copy/paste works ok, but it don't see x11/wayland clipboard.

While this difference for desktop lxterminal and virtual terminal is acceptable, I'm not sure why copy operation don't works in --tty mode on lxterminal.

@unxed
Copy link
Contributor

unxed commented Jan 17, 2025

At the same time when I run far2l --tty from a virtual terminal copy/paste works ok, but it don't see x11/wayland clipboard.

If you mean kernel console, try

DISPLAY=:0 far2l

This will help far2l to connect to XWayland to "see" clipboard.

As for lxterminal, I will look into this.

@unxed
Copy link
Contributor

unxed commented Jan 17, 2025

Could not reproduce the bug in lxterminal under Wayland in my Cinnamon. Probably, labwc-specific issue. Have you filled an issue to it's bug tracker? What do developers say?

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

just checked lxterminal shortcut settings and it appears that Copy shortcut is reset to default value for some unknown reason. I set Ctrl+Insert for Copy operation but copy operation still not works in far2l --tty from lxterminal.

Also tried gnome-terminal and it has the same issue - Copy operation don't works when I start far2l --tty, while Paste operation works ok. gnome-terminal setting also has binding for Copy = Ctrl+Insert and Paste = Shift+Insert.

But there is interesting difference, gnome-terminal don't clear clipboard content when I press Ctrl+Insert in far2l --tty editor. Clipboard content remains unchanged. Exactly the same steps in lxterminal leads to clipboard content clear.

I should note that Copy/Paste operations works ok in far2l --wx on the same labwc desktop, so I don't think that this is labwc issue.

@unxed
Copy link
Contributor

unxed commented Jan 18, 2025

What happens if you set terminal copy key combination to something different, like Alt+Ctrl+Ins, and then try Ctrl+Ins in far2l?

Also, still waiting for far:about screen shot of far2l in lxterminal

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

What happens if you set terminal copy key combination to something different, like Alt+Ctrl+Ins, and then try Ctrl+Ins in far2l?

Just tested setting for lxterminal and gnome-terminal, it appears that behavior don't depends on Copy shorcut binding at all.

For lxterminal pressing Ctrl+Insert leads to clear clipboard content.

For gnome-terminal pressing Ctrl+Insert leads to nothing - Copy operation don't works but clipboard content remains unchanged.

Paste operation works ok on both terminals.

Later I will try to add hook for clipboard to see what is going on with clipboard exactly in this scenario.

Also, still waiting for far:about screen shot of far2l in lxterminal

Image

By the way, I'm not sure where is coming from this 850 / 1252 codepage? My system uses UTF8:

$ locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

Just tested it on Wayland Wayfire backend instead of Labwc. On Wayfire it has exactly the same issue when run far2l --tty from lxterminal or gnome-terminal.

For lxterminal pressing Ctrl+Insert leads to clear clipboard content.

For gnome-terminal pressing Ctrl+Insert leads to nothing - Copy operation don't works but clipboard content remains unchanged.

Paste operation works ok on both terminals.

Also tested far2l --wx on Wayfire - Copy and Paste works ok.

Here is far:about when running far2l --tty from lxterminal on Wayfire:

Image

@unxed
Copy link
Contributor

unxed commented Jan 18, 2025

Thanks! Need to think a bit.

@unxed
Copy link
Contributor

unxed commented Jan 18, 2025

Tried to reproduce on Ubuntu 24.04 (Wayland session, default). Still not reproduced.

Unfortunately, I do not have Pi. Could you please suggest Distro/DE, where I could reproduce an issue on a common x86_64 PC?

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

just tested on Alacritty terminal, it has the same issue - Copy don't works in far2l --tty mode. The behavior is the same as for gnome-terminal - pressing Ctrl+Insert do nothing and clipboard content remains unchanged. Paste operation works ok.

Here is far:about when running on Alacritty:

Image

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

Just tried to add hook on wl_paste and see what happens.

It appears, that when I pressing Ctrl+Insert for selected text in far2l --tty editor running on lxterminal it leads to a single call from wl_paste with empty string (instead of selected text)...

The same steps on gnome-terminal don't trigger wl_paste at all.
I tried Ctrl+C and Ctrl+Insert, but it don't trigger wl_paste event at all...

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

Could you please suggest Distro/DE, where I could reproduce an issue on a common x86_64 PC?

Just tested it on Intel PC running on Linux Arch x64 with KDE Plasma desktop and it shows exactly the same issue for Copy operation in lxterminal and gnome-terminal (Copy operation don't works).

But interesting thing is that when I run far2l --tty from konsole terminal, Copy operation works ok...

Here is far:about from this Linux Arch x64 machine taken on gnome-terminal:

Image

@unxed
Copy link
Contributor

unxed commented Jan 18, 2025

Try to enable osc52 in far2l settings, interface section, and try to copy from far2l in alacritty once again.

Also, please tell exact versions of Arch and Plasma. It would be great if you could provide virualbox or qemu image for testing as I had problems installing Arch to VM then I tried it last time.

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

Try to enable osc52 in far2l settings, interface section, and try to copy from far2l in alacritty once again.

For some unknown reason, there is no such option:

Image

When I started far2l on Arch for the first time, it asked if I want to enable OSC52, I selected Yes, but it don't helps. Copy operation still not works in lxterminal and gnome-terminal.

Also, please tell exact versions of Arch and Plasma. It would be great if you could provide virualbox or qemu image for testing as I had problems installing Arch to VM then I tried it last time.

I installed it manually from installation CD to USB stick. I do it by adding HDD device to VMWare virtual machine with using direct access to USB flash drive instead of hdd image file. Then I boot from this USB stick and installed video driver and other software.

Plasma installed with pacman from the main arch repository.

@unxed
Copy link
Contributor

unxed commented Jan 18, 2025

Thanks! Please: try in alacritty with

far2l --tty --nodetect=x

OSC52 setting should appear in Interface config section. Check that it is on. Try to copy something.

@qrp73
Copy link
Author

qrp73 commented Jan 18, 2025

OSC52 was disabled, I enable it, but it don't helps.
Tested on lxterminal, gnome-terminal and alacritty - the same issue with Copy operation.

@unxed
Copy link
Contributor

unxed commented Jan 29, 2025

Tested far2l as follows:

  1. Run alacritty (installed version is 0.13.2, default settings)
far2l --tty --nodetect=x
  1. Confirm OSC52 is enalbed
  2. Open far2l's editor
  3. Type random strinf
  4. Copied via Ctrl+C
  5. Pasted to Firefox address bar

Worked as expected.

To dig into it deeper I need to reproduce it somehow. I have Mint with Cinnamon, and vanilla Ubuntu 24.04 and KUbuntu 24.10 in VMs.

By the way, as temporary solution, I recommend trying

far2l --clipboard=SCRIPT

Sample SCRIPT for WSL is here:
https://github.com/elfmz/far2l/blob/master/far2l/bootstrap/wslgclip.sh

I don't have version for wayland for now, but it should be easy to adopt it to Wayland using
wl-copy and wl-paste tools from wl-clipboard package.

This is ai-generated adoption, you can try it first:

#!/bin/bash

case "$1" in
get)
    wl-paste
    ;;
set)
    CONTENT=$(cat; echo -n .)
    CONTENT=${CONTENT%.}
    echo -n "$CONTENT" | wl-copy
    echo -n "$CONTENT"
    ;;
"")
    (far2l --clipboard=$(readlink -f $0) >/dev/null 2>&1 &)
    ;;
esac

@qrp73
Copy link
Author

qrp73 commented Jan 31, 2025

As I know using wl-clipboard is not a good way to work with clipboard on wayland, it has a lot of issues, so probably it's better to implement wayland interface and work with clipboard directly, but I don't know details.

@unxed
Copy link
Contributor

unxed commented Jan 31, 2025

To start implementing something I need firstly to reproduce an issue and understand it's reasons.

Btw, does your environment have XWayland? Can you please show me env output from inside far2l?

@qrp73
Copy link
Author

qrp73 commented Feb 3, 2025

yes, it has XWayland. But clipboard in wayland works through clipboard manager interface, in my case simplified wl-clipboard is used (this is out of the box for Raspberry Pi OS)

@unxed
Copy link
Contributor

unxed commented Feb 12, 2025

@akruphi @Dazzar56 any ideas? I have no one left

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants