sentriz / cliphist

wayland clipboard manager with support for multimedia
GNU General Public License v3.0
715 stars 22 forks source link

Items in clipboard history don't properly copy #86

Closed StandingPadAnimations closed 8 months ago

StandingPadAnimations commented 8 months ago

I've been having this issue for a while now where (when using the FZF snippet in the README) I can't paste what I copy from the history anywhere except the terminal.

Looking at the type of what's the type of the item copied using wl-paste, I always get a weird sequence of bytes that changes depending on the copied item

$ cliphist list | fzf | cliphist decode | wl-copy
# selects item

$ wl-paste -l
7PVX

At first I thought it was related to wl-copy being unable to tell the MIME type, but xdg-utils is installed on my system. What's weirder is that if I use --type text/plain or --type image/png, copying works perfectly fine, but again, I have xdg-utils on my system, so this should be automatic.

In addition, I have the proper exec lines in my Hyprland config:

exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store

WAYLAND_DEBUG log when copying:

[3896089.120]  -> wl_display@1.get_registry(new id wl_registry@2)
[3896089.152]  -> wl_display@1.sync(new id wl_callback@3)
[3896089.311] wl_display@1.delete_id(3)
[3896089.332] wl_registry@2.global(1, "wl_shm", 1)
[3896089.341]  -> wl_registry@2.bind(1, "wl_shm", 1, new id [unknown]@4)
[3896089.347] wl_registry@2.global(2, "wl_drm", 2)
[3896089.352] wl_registry@2.global(3, "zwp_linux_dmabuf_v1", 4)
[3896089.356] wl_registry@2.global(4, "wl_compositor", 6)
[3896089.360]  -> wl_registry@2.bind(4, "wl_compositor", 2, new id [unknown]@5)
[3896089.364] wl_registry@2.global(5, "wl_subcompositor", 1)
[3896089.369] wl_registry@2.global(6, "wl_data_device_manager", 3)
[3896089.374]  -> wl_registry@2.bind(6, "wl_data_device_manager", 1, new id [unknown]@6)
[3896089.380] wl_registry@2.global(7, "zwlr_export_dmabuf_manager_v1", 1)
[3896089.385] wl_registry@2.global(8, "zwlr_data_control_manager_v1", 2)
[3896089.389]  -> wl_registry@2.bind(8, "zwlr_data_control_manager_v1", 2, new id [unknown]@7)
[3896089.394] wl_registry@2.global(9, "zwp_primary_selection_device_manager_v1", 1)
[3896089.399]  -> wl_registry@2.bind(9, "zwp_primary_selection_device_manager_v1", 1, new id [unknown]@8)
[3896089.405] wl_registry@2.global(10, "wp_viewporter", 1)
[3896089.409] wl_registry@2.global(11, "zwlr_gamma_control_manager_v1", 1)
[3896089.415] wl_registry@2.global(12, "zwlr_output_power_manager_v1", 1)
[3896089.419] wl_registry@2.global(13, "xdg_wm_base", 6)
[3896089.430]  -> wl_registry@2.bind(13, "xdg_wm_base", 1, new id [unknown]@9)
[3896089.437] wl_registry@2.global(14, "wl_seat", 9)
[3896089.443]  -> wl_registry@2.bind(14, "wl_seat", 2, new id [unknown]@10)
[3896089.452] wl_registry@2.global(15, "wp_presentation", 1)
[3896089.459] wl_registry@2.global(16, "ext_idle_notifier_v1", 1)
[3896089.466] wl_registry@2.global(17, "zwlr_layer_shell_v1", 4)
[3896089.472] wl_registry@2.global(18, "org_kde_kwin_server_decoration_manager", 1)
[3896089.479] wl_registry@2.global(19, "zxdg_decoration_manager_v1", 1)
[3896089.485] wl_registry@2.global(20, "zwlr_output_manager_v1", 4)
[3896089.493] wl_registry@2.global(21, "zwp_keyboard_shortcuts_inhibit_manager_v1", 1)
[3896089.501] wl_registry@2.global(22, "zwp_pointer_constraints_v1", 1)
[3896089.510] wl_registry@2.global(23, "zwp_relative_pointer_manager_v1", 1)
[3896089.518] wl_registry@2.global(24, "zwp_virtual_keyboard_manager_v1", 1)
[3896089.528] wl_registry@2.global(25, "zwlr_virtual_pointer_manager_v1", 2)
[3896089.538] wl_registry@2.global(26, "zwlr_foreign_toplevel_manager_v1", 3)
[3896089.548] wl_registry@2.global(27, "wp_drm_lease_device_v1", 1)
[3896089.557] wl_registry@2.global(28, "zwp_tablet_manager_v2", 1)
[3896089.566] wl_registry@2.global(29, "zwp_idle_inhibit_manager_v1", 1)
[3896089.578] wl_registry@2.global(30, "zxdg_exporter_v1", 1)
[3896089.589] wl_registry@2.global(31, "zxdg_importer_v1", 1)
[3896089.597] wl_registry@2.global(32, "zxdg_exporter_v2", 1)
[3896089.606] wl_registry@2.global(33, "zxdg_importer_v2", 1)
[3896089.614] wl_registry@2.global(34, "zwp_pointer_gestures_v1", 3)
[3896089.623] wl_registry@2.global(35, "zwp_text_input_manager_v3", 1)
[3896089.634] wl_registry@2.global(36, "zwp_input_method_manager_v2", 1)
[3896089.648] wl_registry@2.global(37, "xdg_activation_v1", 1)
[3896089.660]  -> wl_registry@2.bind(37, "xdg_activation_v1", 1, new id [unknown]@11)
[3896089.675] wl_registry@2.global(38, "ext_session_lock_manager_v1", 1)
[3896089.686] wl_registry@2.global(39, "wp_cursor_shape_manager_v1", 1)
[3896089.696] wl_registry@2.global(40, "wp_tearing_control_manager_v1", 1)
[3896089.706] wl_registry@2.global(41, "wp_single_pixel_buffer_manager_v1", 1)
[3896089.715] wl_registry@2.global(42, "xwayland_shell_v1", 1)
[3896089.726] wl_registry@2.global(43, "hyprland_toplevel_export_manager_v1", 2)
[3896089.736] wl_registry@2.global(44, "wp_fractional_scale_manager_v1", 1)
[3896089.745] wl_registry@2.global(45, "zwp_text_input_manager_v1", 1)
[3896089.754] wl_registry@2.global(46, "hyprland_global_shortcuts_manager_v1", 1)
[3896089.763] wl_registry@2.global(47, "zwlr_screencopy_manager_v1", 3)
[3896089.773] wl_registry@2.global(48, "zxdg_output_manager_v1", 3)
[3896089.781] wl_registry@2.global(49, "wl_output", 4)
[3896089.790] wl_callback@3.done(48282)
[3896089.804]  -> wl_display@1.sync(new id wl_callback@3)
[3896090.066] wl_display@1.delete_id(3)
[3896090.099] wl_seat@10.name("seat0")
[3896090.111] wl_seat@10.capabilities(7)
[3896090.119] wl_callback@3.done(48282)
[3896090.131]  -> zwlr_data_control_manager_v1@7.get_data_device(new id zwlr_data_control_device_v1@3, wl_seat@10)
[3897230.982]  -> zwlr_data_control_manager_v1@7.create_data_source(new id zwlr_data_control_source_v1@12)
[3897231.023]  -> zwlr_data_control_source_v1@12.offer("}"nSe")
[3897231.037]  -> zwlr_data_control_device_v1@3.set_selection(zwlr_data_control_source_v1@12)
[3897231.046]  -> wl_display@1.sync(new id wl_callback@13)
[3897231.301] wl_display@1.delete_id(13)
[3897231.325] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190080)
[3897231.340] zwlr_data_control_offer_v1@4278190080.offer("uM_")
[3897231.357] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190080)
[3897231.370]  -> zwlr_data_control_offer_v1@4278190080.destroy()
[3897231.382] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190081)
[3897231.393] zwlr_data_control_offer_v1@4278190081.offer("TEXT")
[3897231.402] zwlr_data_control_offer_v1@4278190081.offer("STRING")
[3897231.409] zwlr_data_control_offer_v1@4278190081.offer("UTF8_STRING")
[3897231.420] zwlr_data_control_offer_v1@4278190081.offer("text/plain")
[3897231.428] zwlr_data_control_offer_v1@4278190081.offer("text/plain;charset=utf-8")
[3897231.441] zwlr_data_control_device_v1@3.primary_selection(zwlr_data_control_offer_v1@4278190081)
[3897231.451]  -> zwlr_data_control_offer_v1@4278190081.destroy()
[3897231.461] zwlr_data_control_device_v1@3.data_offer(new id zwlr_data_control_offer_v1@4278190082)
[3897231.471] zwlr_data_control_offer_v1@4278190082.offer("}"nSe")
[3897231.481] zwlr_data_control_device_v1@3.selection(zwlr_data_control_offer_v1@4278190082)
[3897231.491]  -> zwlr_data_control_offer_v1@4278190082.destroy()
[3897231.502] wl_callback@13.done(48287)
jones-josh commented 8 months ago

I can't reproduce this on my machine at all (I'm running Hyprland also). First thing that comes to mind is the desktop portal - do you have this installed? If so, what version of wl-clipboard do you have (wl-copy --version) and what's the output of the fzf and cliphist decode before being sent to the pipes?

Edit: if the output from cliphist decode is working fine, then this is an issue with wl-copy and not cliphist

StandingPadAnimations commented 8 months ago

I have xdg-desktop-portal-hyprland:

$ pacman -Qi xdg-desktop-portal-hyprland
Name            : xdg-desktop-portal-hyprland
Version         : 1.3.1-3
Description     : xdg-desktop-portal backend for hyprland
Architecture    : x86_64
URL             : https://github.com/hyprwm/xdg-desktop-portal-hyprland
Licenses        : MIT
Groups          : None
Provides        : xdg-desktop-portal-impl
Depends On      : gcc-libs  glibc  hyprlang  libhyprlang.so=0-64  libinih  pipewire  qt6-base  qt6-wayland  sdbus-cpp  util-linux-libs  libuuid.so  wlroots
                  xdg-desktop-portal
Optional Deps   : grim: required for the screenshot portal to function [installed]
                  slurp: support for interactive mode for the screenshot portal [installed]
Required By     : None
Optional For    : xdg-desktop-portal
Conflicts With  : None
Replaces        : None
Installed Size  : 500.23 KiB
Packager        : Caleb Maclennan <alerque@archlinux.org>
Build Date      : Sat 10 Feb 2024 01:10:57 AM CST
Install Date    : Sat 17 Feb 2024 02:25:34 PM CST
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

wl-clipboard version:

$ wl-copy --version
wl-clipboard 2.2.1
Copyright (C) 2018-2023 Sergey Bugaev
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

fzf and cliphist decode both don't seem to have any issues:

$ cliphist list | fzf | cliphist decode
--type text/plain⏎
sentriz commented 8 months ago

what is the output of

$ echo hello | wl-copy
$ wl-paste -l
StandingPadAnimations commented 8 months ago
$ echo hello | wl-copy
$ wl-paste -l
text/html
STRING
text/plain;charset=utf-8
TEXT
UTF8_STRING
text/plain
StandingPadAnimations commented 8 months ago

Actually wait, it might be a shell thing. I did the above in fish, but when executed in Bash, the issue occurs:

$ echo hello | wl-copy
$ wl-paste -l
Mww

EDIT: no, it isn't shell related, as adding quotes around causes the issue in fish


$ echo "hello" | wl-copy
$ wl-paste -l
Ǧ>O'X```
sentriz commented 8 months ago

that is very strange. doesn't happen for me with fish

image

do you have extra processes running which may be copying things to the clipboard? maybe check with pgrep -a "paste|clip|wl|copy"

StandingPadAnimations commented 8 months ago

This is what pgrep -a "paste|clip|wl|copy" on my system

$ pgrep -a "paste|clip|wl|copy"
518 [irq/157-iwlwifi:default_queue]
519 [irq/158-iwlwifi:queue_1]
520 [irq/159-iwlwifi:queue_2]
524 [irq/160-iwlwifi:queue_3]
525 [irq/161-iwlwifi:queue_4]
526 [irq/162-iwlwifi:queue_5]
527 [irq/163-iwlwifi:queue_6]
528 [irq/164-iwlwifi:queue_7]
529 [irq/165-iwlwifi:queue_8]
530 [irq/166-iwlwifi:queue_9]
533 [irq/167-iwlwifi:queue_10]
536 [irq/168-iwlwifi:queue_11]
537 [irq/169-iwlwifi:queue_12]
541 [irq/170-iwlwifi:exception]
491069 wl-paste --type text --watch cliphist store
491071 wl-paste --type image --watch cliphist store

Assuming all the iwlwifi instances are related to networking, nothing seems out of the ordinary

jones-josh commented 8 months ago

Just as something else to try, what about with and without double quotes doing wl-copy hello then pasting after

sentriz commented 8 months ago

the quotes really shouldn't matter since the shell's lexer should stip them out before sending to any program. it seems to me though that this is an issue unrelated to cliphist