Open gerelef opened 3 months ago
COSMIC is looking brilliant, and I'm switching over on WFH machine, but living without Flameshot is unthinkable! :wink: :+1:
Setting the variable XDG_CURRENT_DESKTOP
will also not help:
$ XDG_CURRENT_DESKTOP=COSMIC flameshot
QSocketNotifier: Can only be used with threads started with QThread
flameshot: error: Unable to detect desktop environment (GNOME? KDE? Sway? ...)
flameshot: error: Hint: try setting the XDG_CURRENT_DESKTOP environment variable.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
+1 to fix this on cosmic
Flameshot works fine on COSMIC for me. The only thing that's borked for me is #2848, which seems to be independent of COSMIC.
Flameshot v12.1.0 (-)
Compiled with Qt 5.15.14
Maybe trying newer versions of COSMIC could help? Idk, I'm new to COSMIC too.
I've got the same version of Flameshot and Qt as you and I've updated to the lastest cosmic by removing the version from the Arch repos and installing cosmic-session-git
from the AUR. Unfortunately for me it's not working.
10:23:49 zen ~ flameshot
QSocketNotifier: Can only be used with threads started with QThread
10:24:11 zen ~ flameshot gui
QSocketNotifier: Can only be used with threads started with QThread
flameshot: error: Unable to detect desktop environment (GNOME? KDE? Sway? ...)
flameshot: error: Hint: try setting the XDG_CURRENT_DESKTOP environment variable.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
flameshot: info: Screenshot aborted.
10:24:13 zen ~
Clicking Take Screenshot in the Flameshot system tray applet's menu...
NGL, if the error is this flakey, it seems like a bug in COSMIC than in Flameshot? But I don't know the internals of either software. Would be better if a maintainer commented here.
It seems to me that the code needs some small enhancements to make things work under COSMIC
COSMIC
needs to be added in the enum WM
DesktopInfo::WM DesktopInfo::windowManager()
which needs
if (desktop.contains(QLatin1String("cosmic"))) {
return DesktopInfo::COSMIC;
to be added
Then it should work in COSMIC>
It seems to me that the code needs some small enhancements to make things work under COSMIC
- In src/utils/desktopinfo.h a line
COSMIC
needs to be added in theenum WM
- In src/utils/desktopinfo.cpp there is a function
DesktopInfo::WM DesktopInfo::windowManager()
which needsif (desktop.contains(QLatin1String("cosmic"))) { return DesktopInfo::COSMIC;
to be added
Then it should work in COSMIC>
If you already figured that out, maybe you could create an PR for it? :)
Ok, will do
Hi @manfredlotz. I gave that a go. I made the changes you suggested, and got this...
QSocketNotifier: Can only be used with threads started with QThread
flameshot: warning: grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments
flameshot: error: The universal wayland screen capture adapter requires Grim as the screen capture component of wayland. If the screen capture component is missing, please install it!
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
flameshot: info: Screenshot aborted.
So I install grim
, and got this...
QSocketNotifier: Can only be used with threads started with QThread
flameshot: warning: grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
So there's more to it.
Hm. I am running Arch based EndeavourOS and when I start flameshot gui
in a terminal I get
flameshot: warning: If the USE_WAYLAND_GRIM option is not activated, the dbus protocol will be used. It should be noted that using the dbus protocol under wayland is not recommended. It is recommended to recompile with the USE_WAYLAND_GRIM flag to activate the grim-based general wayland screenshot adapter
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
and I can take a screenshot.
I have to admit that I did nothing special regarding USE_WAYLAND_GRIM
.
Checking with ldd
I see that
libwayland-client.so.0
libwayland-cursor.so.0
are not linked in.
So if I should activate some USE_...
options please tell me where to do that.
Ok, I found out how to build and add USE_...
I did
cmake -B build -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr/local \
-DUSE_WAYLAND_CLIPBOARD=1 -DUSE_WAYLAND_GRIM=1 \
-Wno-dev
and now when running flameshot gui
I get
flameshot: warning: grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
So it seems that I have to make grim's screenshot component happy. But to be honest I do not know enough here about wlroots and such.
I've found that flameshot
is calling grim -
, and complaining if it doesn't exist at all, but if it does, it is not checking its exit status and not complaining - so it doesn't get data because in Cosmic grim -
says that it doesn't support wlr-screencopy-unstable-v1
, and it looks like it has hung because it doesn't show its UI.
The wlr-screencopy-unstable-v1
issue is discussed here. So I believe that shows that the whole problem is grim
and Cosmic not being compatible with each other, and that flameshot
would work if they were.
But I've found a partial workaround.
With the released version of flameshot
installed (I have flameshot-git
installed from the AUR - it doesn't need adding a mention of Cosmic in those two places)...
grim
.grim
file on the path and chmod +x
it. It will use cosmic-screenshot
to take the screenshot before passing it on to flameshot
.
#!/bin/bash
cosmic-screenshot > /dev/null
cat $(ls -tr ~/Pictures/screenshot-*.png | tail -n 1)
flameshot gui
.
flameshot gui
runs, you mark it up.
Yes! Those screenshots are annotated in flameshot
in Cosmic.
There is one major caveat that I haven't found a solution for: copying to the clipboard in 'flameshot' says it copied to the clipboard, but I cannot paste from it. So you have to save the screen shot, and insert it where you want it instead of just Ctrl+Ving where you want it.
Update: If you make your keyboard shortcut do flameshot gui --raw | wl-copy
you'll have a tick button on the toolbar instead of copy and save buttons, and that will successfully copy to the clipboard. Thanks @GetPsyched! #2848
One other thing to note: cosmic-screenshot
takes the screenshot on whichever screen, but flameshot
opens it for annotating only on my leftmost screen (my laptop) which is screen 1 according to cosmic-settings
. It will probably never be a problem. The only reason it might be a problem is if I take a screenshot on my external monitor that is larger than my laptop screen.
And one another: if you exit out of cosmic-screenshot
with the X flameshot
will open the last screenshot, because the grim
script ignores the exit code of cosmic-screenshot
. It has to, since if grim
exits without cat
ting an image to stdout flameshot gui
will continue running in the background and you have to manually kill it.
If flameshot gui
is updated to check the exit code of grim
, grim
could be updated to...
#!/bin/bash
cosmic-screenshot > /dev/null && cat $(ls ~/Pictures/*.png | tail -n 1)
The other things I tried was this...
cosmic-screenshot --interactive=false --save-dir=~/Pictures > /dev/null
cat $(ls ~/Pictures/*.png | tail -n 1)
...but that takes a screenshot of the laptop screen, rather than the current screen. I'll raise an issue about that.
@nevdelap not being able to copy the screenshot is an issue independent of COSMIC AFAIK, it's because of Wayland. See #2848
Flameshot Version
Installation Type
Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)
Operating System type and version
fedora-40; cosmic-desktop DE
Description
Flameshot instantly fatally errors when attempting to take screenshot via any way. Running under cosmic-desktop, installed in fedora 40 via copr
Steps to reproduce
flameshot gui
in the terminalScreenshots or screen recordings
No response
System Information
fedora 40, cosmic-desktop via copr running wayland w/ display layout: