flameshot
flameshot copied to clipboard
Copy to clipboard doesn't work on Wayland
Flameshot Version
Flameshot v12.1.0 (001726a5)
Installation Type
Compiled from source
Operating System type and version
Linux
Description
Almost no copy function work on Wayland, both text or image:
- Ctrl+C or button after creating a screenshot
- "Copy URL" or "Image to Clipboard" on "Upload image" dialog (after uploading image to Imgur)
This one works, might be used as a tip to understand what is wrong in source:
- "Copy URL" in "Upload History" dialog.
Interestingly, this one that works is the only one that doesn't produce any visual response like desktop notification saying "copied to clipboard". Others display a response saying it was copied, but it wasn't.
This is restricted to Wayland, I tried logging with X11 and it works. But it isn't a limitation of Wayland because other apps obviously works fine to copy things to clipboard, be it image or text.
Tried with official openSUSE Tumbleweed package (12.0.0) and compiling latest source by myself, both are affected.
Steps to reproduce
As in description.
Screenshots or screen recordings
No response
System Information
Operating System: openSUSE Tumbleweed 20220725 KDE Plasma Version: 5.25.3 KDE Frameworks Version: 5.96.0 Qt Version: 5.15.5 Kernel Version: 5.18.11-1-default (64-bit) Graphics Platform: Wayland Processors: 12 × AMD Ryzen 5 1600 Six-Core Processor Memory: 31,3 GiB of RAM Graphics Processor: AMD Radeon RX 570 Series
Have you followed https://flameshot.org/docs/guide/wayland-help/#can-t-screen-anything-on-wayland-kde ? Basically have you installed xdg-desktop-portal-kde
and xdg-desktop-portal
?
Yes, both were already installed.
Flameshot is working perfectly here, it's just that it can't copy things to clipboard.
I mentioned above in "Descrption" the only situation in which copying to clipboard is working, I guess it might help to investigate the root of the issue, looking into differences in source between that one and other "copy to clipboard" functions.
Same happens on NixOS with KDE 5.23.3 and flameshot-12.1.0.
I've been using NixOS with KDE for several months and copying to keyboard using CTRL-C
shortcut never worked.
I've been using NixOS with KDE for several months and copying to keyboard using CTRL-C shortcut never worked.
Just to make sure, you have checked that you are on Wayland, and in the Flameshot config Ctrl-c is bound to copy?
Yes, 100% on wayland:
$ echo $XDG_SESSION_TYPE
wayland
Here is the snipped from Flameshot config screen:
Other shortcuts like Ctrl+S
work just fine.
When I press Ctrl-C
it does say "Capture saved to clipboard" but it's not actually.
Just to make sure, you have checked that you are on Wayland, and in the Flameshot config Ctrl-c is bound to copy?
Just to be clear, the issue is not related to key pressing, because (1) every other shortcut is working and (2) it's still a issue when you try to copy to clipboard by clicking screen buttons instead of using shortcuts (with one single working exception as described in first comment).
It's working from the notification pop menu (as in below), I guess it's coming from Plasma at this stage, not flameshot.
I'd like to see if this helps once I manage to build it on Nix
I'd like to see if this helps once I manage to build it on Nix
Thank you, that fixed part of the issue.
After building with cmake ../ -DUSE_WAYLAND_CLIPBOARD=true
, copying image now works on Wayland, both by Ctrl+C and by clicking button.
But it still not perfect because copying URL string on upload still doesn't work. A desktop notification displays it was copied, but it wasn't. And if I click Copy URL
button from "Upload image" dialog it also doesn't work:
But from "Upload History" dialog, as I said in initial comment clicking in Copy URL
does work.
So now for this last remaining issue I believe it's something fixable in Flameshot code because there's already a place in which copy URL command works.
Is there any reason for not using -DUSE_WAYLAND_CLIPBOARD=true
in official binaries? As I said in previous comment, it fixes part of this Wayland issue. Now I just tested on X11 and it works on there too, so for me at least there's no negative side effect on compiling with that flag.
So I managed to recompile flameshot with -DUSE_WAYLAND_CLIPBOARD=true
on NixOS and now both Ctrl-C
and clicking button work! Hooray!
If anyone is on NixOS, you can put the following snippet into a separate file and include in your configuration.nix
(make sure to remove flameshot
from your package list in other places of course):
{ config, pkgs, ... }:
let
flameshotPin = import (pkgs.fetchFromGitHub {
owner = "haizaar";
repo = "nixpkgs";
rev = "ca6081cbce02589ad9594350ce6e5bca39b09ad1";
sha256 = "6lOu2O4KAYfGccHdZQUEr2A3mdwEtcr3S7pyLxxlZII=";
}) {};
in {
environment.systemPackages = [ flameshotPin.flameshot ];
}
The only downside is that using it introduces dependency on kguiaddons
which is probably not necessary for GNOME users.
But definitely it's a great progress!
So I managed to recompile flameshot with -DUSE_WAYLAND_CLIPBOARD=true on NixOS and now both Ctrl-C and clicking button work! Hooray!
But just image copying, right? What about auto path copying on save and auto URL copying on upload? These are still not working for me.
Yes, just the image copying. Getting file path after save into clipboard still doesn't work :/
Well, I was curious enough to fix it by myself.
As said above, recompiling with -DUSE_WAYLAND_CLIPBOARD=true
fixes copying image. Here is the code:
https://github.com/flameshot-org/flameshot/blob/54690d5be8d8b23ff4736bda553e99de1a8bc9a7/src/utils/screenshotsaver.cpp#L109-L114
So I simply done the exact same thing for copying text, which still doesn't work with current source even with that compile flag:
+
+#if USE_WAYLAND_CLIPBOARD
+#include <KSystemClipboard>
+#include <QMimeData>
+#endif
+
void FlameshotDaemon::attachTextToClipboard(QString text, QString notification)
{
// Must send notification before clipboard modification on linux
if (!notification.isEmpty()) {
AbstractLogger::info() << notification;
}
m_hostingClipboard = true;
+
+#ifdef USE_WAYLAND_CLIPBOARD
+ auto* mimeData = new QMimeData();
+ mimeData->setText(text);
+ KSystemClipboard::instance()->setMimeData(mimeData,
+ QClipboard::Clipboard);
+#else
QClipboard* clipboard = QApplication::clipboard();
clipboard->blockSignals(true);
// This variable is necessary because the signal doesn't get blocked on
// windows for some reason
m_clipboardSignalBlocked = true;
clipboard->setText(text);
clipboard->blockSignals(false);
+#endif
}
Recompiled and copying path and URL is now working!
It seems to be working perfectly, but I'm not sure if that's the optimal way to fix so I didn't submit a PR.
@borgmanJeremy what do you think about https://github.com/flameshot-org/flameshot/issues/2848#issuecomment-1199796142
Yes I think that is a good change to make. Im also fine with changing the packages to include the wayland clipboard dependencies as long as someone else does it. Not all distro's support it and I hate spending time on packaging.
Just out of curiosity: is this change bound to happen then?
@morrolinux the situation is that we are open to this change but we need someone to step up, do it, and keep maintaining it. Are you interested to contribute regarding this matter?
On arch the official package already builds with said flag, yet it still does not work with everything else being fine except for actually copying the screenshot. I am using DWL as my compositor, and desktop portals are functioning correctly.
Edit: It seems like saving to a file does not work either.
Same on Ubuntu 22.04 on Gnome/Wayland. Clicking copy here or hitting Ctrl+C seems to think it's being done successfully, but the clipboard is empty.
Also possibly related, Ctrl+S does nothing at all, but the save to file icon works. The shortcuts are configured correctly.
I can confirm it for Zorin OS 16.1, which is basically Ubuntu 20.04 LTS with Gnome But I think it's not the OS Problem, as it worked very well with Ubuntu 20.04 LTS itself. Therefore I tried different installations: the snaps didn't work, the installation from flathub (all Versions 12) copies to clipboard see also https://github.com/flameshot-org/flameshot/issues/2857#issuecomment-1242999573
@https://github.com/flameshot-org/flameshot/issues/2813
I sketched a little script to easy build and install flameshot with USE_WAYLAND_CLIPBOARD
flag enabled on debian based distros.
It also respects new version if it will be released.
#!/bin/bash
set -e
rm -rf build
mkdir -p build
cd build
sudo apt install devscripts equivs libkf5guiaddons-dev -y
sudo mk-build-deps -t'apt-get -y' -ir flameshot
apt source flameshot
SRC_DIR=`ls | cut -f1 | head -n1`
pushd ${SRC_DIR}
sed -i 's/-DFLAMESHOT_ABOUT_DEB_VERSION/-DUSE_WAYLAND_CLIPBOARD=1 -DFLAMESHOT_ABOUT_DEB_VERSION/' debian/rules
[email protected] dch -n ''
debuild -i -j -us -uc
popd
sudo apt purge flameshot-build-deps devscripts equivs libkf5guiaddons-dev --auto-remove -y
sudo dpkg -i flameshot_*.deb
rm -rf ../build
But it still not perfect because copying URL string on upload still doesn't work.
The workaround to fix this remaining issue is launching flameshot with GDK_BACKEND=x11
.
The workaround to fix this remaining issue is launching flameshot with
GDK_BACKEND=x11
.
Didn't work for me on Kubuntu 22.10
So, since i had already invested hours in trying to even make flameshot open in hyprland, I decided to get this working no matter what.
I just found out that the image is actually copied in wl-copy, but pasting it doesn't work unless i do this:
wl-paste | wl-copy
which works. I have no idea why, but i hope it'll help someone in the meantime...
I also found out that up to a certain size of the screenshot, let's say 150x150, copying straight from flameshot works, but if make a bigger one, it doesn't work anymore, until i run the aforementioned command. Might even be an issue with wl-copy, I don't know.
As of right now I made this command for copyq that makes it work flawlessly
[Command]
Automatic=true
Command="
bash:
wl-paste | wl-copy"
Icon=\xf021
Input=image/png
Name=refresh wlcopy
Copying to clipboard works if we run:
flameshot gui --raw | wl-copy
Same problem on Arch Linux and Flameshot v12.1.0 (-) compiled with Qt 5.15.5.
The Arch Linux package is compiled with -DUSE_WAYLAND_CLIPBOARD=1
Copying to clipboard works if we run:
flameshot gui --raw | wl-copy
Only this solution worked for me @ Hyprland even though i compiled with the -DUSE_WAYLAND_CLIPBOARD=1
flag
It's still an issue with
Operating System: Kubuntu 23.04 KDE Plasma Version: 5.27.4 KDE Frameworks Version: 5.104.0 Qt Version: 5.15.8 Kernel Version: 6.2.0-25-generic (64-bit) Graphics Platform: Wayland Processors: 4 × Intel® Core™ i5-4460 CPU @ 3.20GHz Memory: 7.6 GiB of RAM Graphics Processor: Mesa Intel® HD Graphics 4600 Manufacturer: MSI Product Name: MS-7817 System Version: 1.0
This workaround works, albeit cumbersome. Need to install wl-copy. You will lose the ability to save to file directly.
Can confirm that this patch works for me and fixes the issue of the uploaded image URL not being copied to clipboard (arch/wayland/plasma).