hluk / CopyQ

Clipboard manager with advanced features
GNU General Public License v3.0
8.26k stars 430 forks source link

Paste not working with Hyprland (wayland support script enabled) #2557

Closed Gufderald closed 6 months ago

Gufderald commented 7 months ago

Before creating a new issue, see list of known issues.

This issue is in list of known issues; however, I will start an issue here as there may be a workaround for this behaviour

Describe the bug I'm creating this issue to continue discussion in https://github.com/hluk/CopyQ/issues/27, as it's closed.

I'm running Arch with Hyprland compositor. After enabling wayland support script everything runs smooth, except paste behavior ONLY in terminal emulators - instead of the clipboard content, it inserts something else. It seems to be related to the paste shortcut, which wayland support script sends and which seems to be Shift+Insert. As it is not paste shortcut by default in most terminal emulators - the issue occurs.

To Reproduce Steps to reproduce the behavior:

  1. Use Hyprland and wayland support script
  2. Try to paste smth from clipboard to your terminal emulator using enter on the copyq window.

Expected behavior Insert selected clipboard entry to the terminal

Version, OS and Environment CopyQ Clipboard Manager 7.1.0 Qt: 5.15.10 KNotifications: 5.110.0 Compiler: GCC Arch: x86_64-little_endian-lp64 OS: Arch Linux ! Hyprland, wayland support script enabled

Gufderald commented 7 months ago

For now I found a workaround - mapping Shft+Insert chord to a paste action - it works for gnome terminal at least.

Gufderald commented 7 months ago
  - { key: Insert,         mods: Shift,                           action: Paste            }

For alacritty this line should be set instead of PasteSelection action

Gufderald commented 7 months ago

Created another issue in https://github.com/hluk/copyq-commands; created MR with edited README for wayland support script.

gowallasnewpony commented 7 months ago

would this eventually help?: https://github.com/hluk/CopyQ/issues/633

hluk commented 7 months ago

I picked Shift+Insert because it actually is the default shortcut for pasting (clipboard or selection) in most terminal emulators and applications.

You can try modifying the paste() function to send Ctrl+Shift+V for pasting:

    global.paste = function() {
        sendShortcut('42:1', '29:1', '47:1', '47:0', '29:0', '42:0')
    }
Gufderald commented 7 months ago

would this eventually help?: #633

Thanks, I'll give it a try.

Gufderald commented 7 months ago

I picked Shift+Insert because it actually is the default shortcut for pasting (clipboard or selection) in most terminal emulators and applications.

You can try modifying the paste() function to send Ctrl+Shift+V for pasting:

    global.paste = function() {
        sendShortcut('42:1', '29:1', '47:1', '47:0', '29:0', '42:0')
    }

Thanks! However, changing shortcut to Ctrl+Shift+V will break paste actions for most applications.

hluk commented 7 months ago

However, changing shortcut to Ctrl+Shift+V will break paste actions for most applications.

Yeah, I thought it might be the case (I only tested it in Firefox and kitty terminal emulator).

Alternate solution would be to check the current window title before triggering the paste:

global.paste = function() {
    const window = currentWindowTitle();
    if (window == 'Alacritty') {
        // Shift+Ctrl+V
        sendShortcut('42:1', '29:1', '47:1', '47:0', '29:0', '42:0');
    } else {
        // Shift+Insert
        sendShortcut('42:1', '110:1', '110:0', '42:0');
    }
}
Gufderald commented 6 months ago

Hi! My mr to docs for scripts was merged, so I suppose this may be closed. I tested sollutions from @gowallasnewpony and @hluk - they both works fine as a workaround too, thanks a lot.