Copying images causes it to copy links with formatting

I’m going to assume this is an issue created by something I screwed up with wl-copy, but copying an image in the browser (right click copy image) presents the link with formatting.

For example I have copied the garuda logo in the top left of the forum homepage, yielding this result.

<meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="https://forum.garudalinux.org/uploads/default/original/3X/7/7/779e2933e2b91d81b7f27db2f2317a110b8a3d8f.webp" alt="Garuda Linux Forum" id="site-logo" class="logo-big">

This isn’t an individual browser issue, it happens across every browser I tested.

inxi if it’s helpful

System:
  Kernel: 6.7.6-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 13.2.1
    clocksource: tsc avail: hpet,acpi_pm
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=4b2cde03-ef4b-44e6-9894-6c8dce837fad rw rootflags=subvol=@
    radeon.si_support=0 amdgpu.si_support=1 radeon.cik_support=0
    amdgpu.cik_support=1 quiet
    resume=UUID=b139276a-c0ac-4db7-bc3a-efa94bc78d77 loglevel=3 ibt=off
  Desktop: Hyprland v: 0.35.0-107-g98034fea tools: avail: swayidle,swaylock
    vt: 1 dm: SDDM Distro: Garuda base: Arch Linux
Machine:
  Type: Desktop System: Gigabyte product: B450M DS3H WIFI v: -CF
    serial: <superuser required>
  Mobo: Gigabyte model: B450M DS3H WIFI-CF v: x.x
    serial: <superuser required> uuid: <superuser required> UEFI: American
    Megatrends LLC. v: F64 date: 11/07/2022
CPU:
  Info: model: AMD Ryzen 5 3600 bits: 64 type: MT MCP arch: Zen 2 gen: 3
    level: v3 note: check built: 2020-22 process: TSMC n7 (7nm)
    family: 0x17 (23) model-id: 0x71 (113) stepping: 0 microcode: 0x8701021
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB
    L3: 32 MiB desc: 2x16 MiB
  Speed (MHz): avg: 3666 high: 3995 min/max: 2200/4208 boost: enabled
    scaling: driver: acpi-cpufreq governor: performance cores: 1: 3600 2: 3594
    3: 3600 4: 3995 5: 3600 6: 3599 7: 3600 8: 3600 9: 3788 10: 3625 11: 3600
    12: 3793 bogomips: 86230
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3
  Vulnerabilities: <filter>
Graphics:
  Device-1: AMD Hawaii PRO [Radeon R9 290/390] vendor: Micro-Star MSI
    driver: amdgpu v: kernel alternate: radeon arch: GCN-2 code: Sea Islands
    process: GF/TSMC 16-28nm built: 2013-17 pcie: gen: 3 speed: 8 GT/s
    lanes: 16 ports: active: DP-1,DVI-D-1 empty: DVI-D-2,HDMI-A-1
    bus-ID: 0a:00.0 chip-ID: 1002:67b1 class-ID: 0300 temp: 61.0 C
  Display: wayland server: X.org v: 1.21.1.11 with: Xwayland v: 23.2.4
    compositor: Hyprland v: 0.35.0-107-g98034fea driver: X: loaded: radeon
    unloaded: modesetting alternate: fbdev,vesa dri: radeonsi gpu: amdgpu
    display-ID: 1
  Monitor-1: DP-1 model: ASUS VG24VQ1B serial: <filter> built: 2021
    res: 1920x1080 dpi: 93 gamma: 1.2 size: 527x296mm (20.75x11.65")
    diag: 604mm (23.8") ratio: 16:9 modes: max: 1920x1080 min: 720x400
  Monitor-2: DVI-D-1 model: Apple Cinema serial: <filter> built: 2007
    res: 1680x1050 dpi: 99 gamma: 1.2 size: 433x270mm (17.05x10.63")
    diag: 510mm (20.1") ratio: 16:10 modes: max: 1680x1050 min: 640x480
  API: Vulkan v: 1.3.276 layers: 14 device: 0 type: discrete-gpu name: AMD
    Radeon R9 390 Series (RADV HAWAII) driver: mesa radv v: 24.0.1-arch1.1
    device-ID: 1002:67b1 surfaces: xcb,xlib,wayland device: 1 type: cpu
    name: llvmpipe (LLVM 16.0.6 256 bits) driver: mesa llvmpipe
    v: 24.0.1-arch1.1 (LLVM 16.0.6) device-ID: 10005:0000
    surfaces: xcb,xlib,wayland
  API: EGL Message: EGL data requires eglinfo. Check --recommends.
Audio:
  Device-1: AMD Hawaii HDMI Audio [Radeon R9 290/290X / 390/390X]
    vendor: Micro-Star MSI driver: snd_hda_intel v: kernel pcie: gen: 3
    speed: 8 GT/s lanes: 16 bus-ID: 0a:00.1 chip-ID: 1002:aac8 class-ID: 0403
  Device-2: AMD Starship/Matisse HD Audio vendor: Gigabyte
    driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
    bus-ID: 0c:00.4 chip-ID: 1022:1487 class-ID: 0403
  Device-3: Razer USA Kraken Kitty Edition
    driver: hid-generic,snd-usb-audio,usbhid type: USB rev: 2.0 speed: 12 Mb/s
    lanes: 1 mode: 1.1 bus-ID: 1-5.3:7 chip-ID: 1532:0521 class-ID: 0300
    serial: <filter>
  API: ALSA v: k6.7.6-zen1-1-zen status: kernel-api tools: N/A
  Server-1: sndiod v: N/A status: off tools: aucat,midicat,sndioctl
  Server-2: PipeWire v: 1.0.3 status: active with: 1: pipewire-pulse
    status: active 2: wireplumber status: active 3: pipewire-alsa type: plugin
    4: pw-jack type: plugin tools: pactl,pw-cat,pw-cli,wpctl
Network:
  Device-1: Realtek RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet
    vendor: Gigabyte driver: r8169 v: kernel pcie: gen: 1 speed: 2.5 GT/s
    lanes: 1 port: e000 bus-ID: 05:00.0 chip-ID: 10ec:8168 class-ID: 0200
  IF: enp5s0 state: up speed: 1000 Mbps duplex: full mac: <filter>
  Device-2: Realtek RTL8821CE 802.11ac PCIe Wireless Network Adapter
    vendor: AzureWave driver: rtw_8821ce v: N/A modules: rtw88_8821ce pcie:
    gen: 1 speed: 2.5 GT/s lanes: 1 port: d000 bus-ID: 07:00.0
    chip-ID: 10ec:c821 class-ID: 0280
  IF: wlp7s0 state: down mac: <filter>
  Info: services: NetworkManager, systemd-timesyncd, wpa_supplicant
Bluetooth:
  Device-1: IMC Networks Bluetooth Radio driver: btusb v: 0.8 type: USB
    rev: 1.1 speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-7:4 chip-ID: 13d3:3533
    class-ID: e001 serial: <filter>
  Report: btmgmt ID: hci0 rfk-id: 1 state: up address: <filter> bt-v: 4.2
    lmp-v: 8 status: discoverable: no pairing: no class-ID: 6c0104
Drives:
  Local Storage: total: 2.29 TiB used: 341.34 GiB (14.6%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Crucial model: CT500P3SSD8
    size: 465.76 GiB block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s
    lanes: 4 tech: SSD serial: <filter> fw-rev: P9CR30A temp: 27.9 C
    scheme: GPT
  ID-2: /dev/sda maj-min: 8:0 vendor: Western Digital
    model: WDS500G2B0A-00SM50 size: 465.76 GiB block-size: physical: 512 B
    logical: 512 B speed: 6.0 Gb/s tech: SSD serial: <filter> fw-rev: 20WD
    scheme: GPT
  ID-3: /dev/sdb maj-min: 8:16 vendor: SanDisk model: SDSSDH3 1T00
    size: 931.51 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 20RL scheme: MBR
  ID-4: /dev/sdc maj-min: 8:32 vendor: TeamGroup model: T253512GB
    size: 476.94 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    tech: SSD serial: <filter> fw-rev: 61.5 scheme: MBR
Partition:
  ID-1: / raw-size: 448.37 GiB size: 448.37 GiB (100.00%)
    used: 341.34 GiB (76.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-2: /boot/efi raw-size: 300 MiB size: 299.4 MiB (99.80%)
    used: 584 KiB (0.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
  ID-3: /home raw-size: 448.37 GiB size: 448.37 GiB (100.00%)
    used: 341.34 GiB (76.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-4: /var/log raw-size: 448.37 GiB size: 448.37 GiB (100.00%)
    used: 341.34 GiB (76.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
  ID-5: /var/tmp raw-size: 448.37 GiB size: 448.37 GiB (100.00%)
    used: 341.34 GiB (76.1%) fs: btrfs dev: /dev/nvme0n1p2 maj-min: 259:2
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default) zswap: no
  ID-1: swap-1 type: zram size: 15.54 GiB used: 90.2 MiB (0.6%)
    priority: 100 comp: zstd avail: lzo,lzo-rle,lz4,lz4hc,842 max-streams: 12
    dev: /dev/zram0
  ID-2: swap-2 type: partition size: 17.09 GiB used: 0 KiB (0.0%)
    priority: -2 dev: /dev/nvme0n1p3 maj-min: 259:3
Sensors:
  System Temperatures: cpu: 45.8 C mobo: 26.0 C gpu: amdgpu temp: 61.0 C
  Fan Speeds (rpm): N/A gpu: amdgpu fan: 489
Info:
  Memory: total: 16 GiB available: 15.54 GiB used: 4.7 GiB (30.3%)
  Processes: 379 Power: uptime: 13m states: freeze,mem,disk suspend: deep
    avail: s2idle wakeups: 0 hibernate: platform avail: shutdown, reboot,
    suspend, test_resume image: 6.2 GiB services: upowerd Init: systemd v: 255
    default: graphical tool: systemctl
  Packages: 1831 pm: pacman pkgs: 1822 libs: 480 tools: pacseek,pamac,paru
    pm: flatpak pkgs: 9 Compilers: clang: 16.0.6 gcc: 13.2.1 alt: 12
    Shell: garuda-inxi default: fish v: 3.7.0 running-in: kitty inxi: 3.3.33
Garuda (2.6.23-1):
  System install date:     2024-01-23
  Last full system update: 2024-02-29 ↻
  Is partially upgraded:   No
  Relevant software:       snapper NetworkManager dracut
  Windows dual boot:       No/Undetected
  Failed units:      

Same here.
I expected to be able to paste the image rather than the html in a paint program, but no.
Nor could I paste as image with wl-paste -t image/webp, seems like it’s copied as text/html only (have to check this).

This part of the wl-copy man page may be relevant

wl-copy automatically infers the type of the copied content by running xdg-mime(1) on it. wl-paste tries its best to pick a type to paste based on the list of offered MIME types and the extension of the file it’s pasting into. If you’re not satisfied with the type they pick or don’t want to rely on this implicit type inference, you can explicitly specify the type to use with the –type option.

except I’m not sure how browsers use the clipboard.

Let’s see what others have to say, to me it doesn’t seem to be a misconfiguration on your side though (or I managed to misconfigure it the same way LOL).

1 Like

What clipboard manager is in use? Does the clipboard manager have a stored value which is the image? If you kill the clipboard manager, is the normal copy/paste behavior restored?

If it’s not the clipboard manager, my next guess would be whatever version of xdg-desktop-portal is in use.

2 Likes

My settings :wink:

#exec-once=copyq
#exec-once=wl-paste -t text --watch clipman store
#exec-once=wl-clipboard-history -t

Copy and paste to Inkscape works. I do not need and like copyq :smiley:

pacman -Qi  xdg-desktop-portal
Name                     : xdg-desktop-portal
Version                  : 1.18.2-1
Beschreibung             : Desktop integration portals for sandboxed apps
Architektur              : x86_64
URL                      : https://flatpak.github.io/xdg-desktop-portal/
Lizenzen                 : LGPL
Gruppen                  : Nichts
Stellt bereit            : Nichts
Hängt ab von             : fuse3  gdk-pixbuf2  geoclue  glib2  pipewire  rtkit  systemd
Optionale Abhängigkeiten : xdg-desktop-portal-impl: Portal backends [Installiert]
Benötigt von             : libportal  xdg-desktop-portal-hyprland
Optional für             : firedragon  flameshot-git  floorp  librewolf  signal-desktop  telegram-desktop

I am using wl-clipboard-history and technically copq as I have that segment of the default garuda-hyprland config unchanged.

Hm, I do have clipman installed, first reference in pacman.log is 2021-12-03 which is the same day I installed.
Not 100% sure but I take it to mean that clipman is/was from the install ISO.

fish❯ head -1 /var/log/pacman.log
[2021-12-03T17:37:56+0100] [PACMAN] Running 'pacman --noconfirm --cachedir /var/cache/pacman/pkg --config /opt/mhwd/pacman-mhwd.conf --root / --needed -Sy garuda-video-linux-config'
fish❯ grep 'clipman' /var/log/pacman.log |head -4
[2021-12-03T17:38:48+0100] [ALPM-SCRIPTLET] clipman 1.6.0-1
[2021-12-03T17:48:27+0100] [ALPM] upgraded clipman (1.6.0-1 -> 1.6.1-1)
[2021-12-04T06:17:35+0100] [ALPM-SCRIPTLET] Found snapshot: 2021-12-03 17:49:56 | @/.snapshots/2/snapshot  | post | alacritty ca-certificates-mozilla clipman device-mapper garuda-assistant
[2023-04-26T19:47:39+0200] [ALPM] upgraded clipman (1.6.1-1 -> 1.6.2-1)
fish❯ pacman -Qi  xdg-desktop-portal clipman
Name            : xdg-desktop-portal
Version         : 1.18.2-1
Description     : Desktop integration portals for sandboxed apps
Architecture    : x86_64
URL             : https://flatpak.github.io/xdg-desktop-portal/
Licenses        : LGPL
Groups          : None
Provides        : None
Depends On      : fuse3  gdk-pixbuf2  geoclue  glib2  pipewire  rtkit  systemd
Optional Deps   : xdg-desktop-portal-impl: Portal backends [installed]
Required By     : imhex  libportal  xdg-desktop-portal-gtk  xdg-desktop-portal-wlr
Optional For    : firedragon
Conflicts With  : None
Replaces        : None
Installed Size  : 2.28 MiB
Packager        : Jan Alexander Steffens (heftig) <[email protected]>
Build Date      : gio 23 nov 2023, 00:02:28
Install Date    : dom 26 nov 2023, 20:14:43
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

Name            : clipman
Version         : 1.6.2-1
Description     : A simple clipboard manager for Wayland
Architecture    : x86_64
URL             : https://github.com/yory8/clipman
Licenses        : GPL3
Groups          : None
Provides        : clipman
Depends On      : wl-clipboard>=2.0
Optional Deps   : None
Required By     : None
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 3.74 MiB
Packager        : Nico Jensch <[email protected]>
Build Date      : mar 25 apr 2023, 16:15:03
Install Date    : mer 6 set 2023, 10:03:35
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

No wl-clipboard-history, no copyq.
I installed yank but that does not seem relevant.

1 Like

Which DE? :slight_smile:

(derp) Sway.

1 Like

Syncing clipboards in Wayland breaks image copy from browser / Applications & Desktop Environments / Arch Linux Forums

Copying the image twice as reported at Copying an image copies html tags instead · Issue #120 · bugaevc/wl-clipboard · GitHub, weird as it sounds, works to copy as image.

Image copy/paste is working normally for me on Sway with cliphist and wl-clipboard.

❯ pacman -Qs clip
local/cliphist 1:0.5.0-1
    wayland clipboard manager
local/wl-clipboard 1:2.2.1-1
    Command-line copy/paste utilities for Wayland

If I invoke cliphist, it does show me the html tags as an option to pull to the clipboard, but by default it uses the image as normal. Ctrl+C and Ctrl+V will just paste the image.

In addition to xdg-desktop-portal, I also have xdg-desktop-portal-wlr installed.

❯ pacman -Qs xdg-desktop
local/xdg-desktop-portal 1.18.2-1
    Desktop integration portals for sandboxed apps
local/xdg-desktop-portal-wlr 0.7.0-2
    xdg-desktop-portal backend for wlroots
1 Like
libportal 0.7.1-2               GIO-style async APIs for most Flatpak portals
libportal-gtk3 0.7.1-2          GIO-style async APIs for most Flatpak portals - GTK 3 backend
xdg-desktop-portal 1.18.2-1     Desktop integration portals for sandboxed apps
xdg-desktop-portal-gtk 1.15.1-1 A backend implementation for xdg-desktop-portal using GTK
xdg-desktop-portal-wlr 0.7.0-2  xdg-desktop-portal backend for wlroots
clipman 1.6.2-1                 A simple clipboard manager for Wayland
unipicker 2.0.1-1               CLI utility for searching unicode characters by description and copy them to the clipboard
wl-clipboard 1:2.2.1-1          Command-line copy/paste utilities for Wayland
yank 1.3.0-1                    Copy terminal output to clipboard

these seem to be all the portal and clipboard related packages I have installed, and I’d say it’s safe to ignore yank and unipicker.
I get the same behavior as in the GitHub issue, first copy is only a few text formats, second one has them all. At least when copying from Firedragon browser. I have not tested other combinations of source and destination.
I guess I should try with clipman store -P or cliphist maybe.
I have these two lines in ~/.config/sway/config.d/autostart_applications

38:exec clipman restore
39:exec wl-paste -t text --watch clipman store

and, at least in my case, the problem may be there (-t text and no -P).
Will check later.


Ah, from man clipman:

KNOWN ISSUES
       We only support plain text.

       By default, we continue serving the last copied item even after its owner has exited.  This means that, unless you run with the ‘--no-persist‘  option,  you'll  always  immediately
       lose  rich content; for example: vim's visual block mode breaks; copying images in Firefox breaks; if you copy a bookmark in Firefox, you won't be able to paste it in another book‐
       mark folder; if you copy formatted text inside Libre Office you'll lose all formatting on paste.

       Run ‘clipman store‘ with the ‘--no-persist‘ option if you are affected. Unfortunately, it seems that there is no way to make them play well together.

copying images in Firefox breaks


and… this is something I forgot to update and merge: the /etc/skel/copy has instead

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

Hmm… when I open copyQ then it shows the logo, not the link in history but when I do wl-paste , then it will give me links with formatting,
okay seems like we need to change now copyQ with something :sweat_smile:

2 Likes

Those are from switching to Cliphist a couple months back. You don’t need to add those lines unless you want to switch from Clipman to Cliphist.

There is a little extra configuration involved if you want to go that route; here is the commit for reference:

Disregard the swayr thing on there; it is completely unrelated (it probably should have been a separate commit).

I set up Cliphist with Fuzzel, but you can use Wofi or any other picker instead if you want.

Now that I think of it, it may be that this image copying thing was the whole reason I switched from Clipman to Cliphist–I can’t remember for sure though. :thinking:

2 Likes

do :

sudo pacman -R copyq
sudo pacman -S cliphist 

Add these lines in config

# Clipboard Manager
exec-once = wl-paste --type text --watch cliphist store #Stores only text data
exec-once = wl-paste --type image --watch cliphist store #Stores only image data
bind = SUPER, V, exec, cliphist list | wofi --dmenu | cliphist decode | wl-copy

and remove

exec-once = copyq
5 Likes

i WAS having the same copy+paste issue using copyq but this seems to have solved it… Thanks bud!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.