flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
24.74k stars 1.58k forks source link

Does not work when using Plasma+Wayland #1380

Closed abhijeetviswa closed 3 years ago

abhijeetviswa commented 3 years ago

Versions Flameshot: 5b0bb501dc513f16e93a6d72e06a222a2da6c404 Kwin/Plasma: v5.21 Distro: Arch Protocol: Wayland

Describe the bug Flameshot does not take a screenshot. I tried tracking this down with the hopes of creating a patch, but I'm SOL due to my limited knowledge in the Linux desktop space. These are my findings:

I tried setting the Exec key full path to the binary as well as changing the X-KDE-DBUS-Restricted-Interfaces key to the intended value. However, Flameshot still does not work. I hope someone can fix this issue or help track this down further.

Thanks and sorry if a similar issue already exists.

borgmanJeremy commented 3 years ago

What distro are you testing with?

abhijeetviswa commented 3 years ago

Arch Linux Should've specified that. My bad. I'll eid the issue as well.

borgmanJeremy commented 3 years ago

I can confirm this is an issue, luckily its not related to the 0.9 release. it is also present on the 0.8.5 branch. I wonder if its our fault or related to the recent KWIN changes.

borgmanJeremy commented 3 years ago

Do you have a good way to rollback to Plasma 5.20?

abhijeetviswa commented 3 years ago

Flameshot did not work on Plasma 5.20 + Wayland. I'm not sure if the issue was the same as it is now. Any tips on how to rollback to 5.20 on Arch?

borgmanJeremy commented 3 years ago

Not sure how to do it safely either 😀

abhijeetviswa commented 3 years ago

Upgraded to Plasma 5.21.1. With the changes I had made to the .desktop file, Flameshot has started working once again.

abhijeetviswa commented 3 years ago

Here is a git diff of the changes I made. Could you try it out locally and let me know if this works for you?

diff --git a/data/desktopEntry/package/org.flameshot.Flameshot.desktop b/data/desktopEntry/package/org.flameshot.Flameshot.desktop
index a5308e3..eac291c 100644
--- a/data/desktopEntry/package/org.flameshot.Flameshot.desktop
+++ b/data/desktopEntry/package/org.flameshot.Flameshot.desktop
@@ -37,7 +37,7 @@ Keywords[nl_NL]=flameshot;schermfoto;screenshot;schermafdruk;vastleggen;schermop
 Keywords[es]=flameshot;screenshot;capture;shutter;captura;
 Keywords[de]=flameshot;screenshot;Bildschirmfoto;Aufnahme;
 Keywords[pt_BR]=flameshot;screenshot;captura de tela;captura;shutter;
-Exec=flameshot
+Exec=/usr/bin/flameshot
 Icon=org.flameshot.Flameshot
 Terminal=false
 Type=Application
@@ -46,7 +46,7 @@ StartupNotify=false
 Actions=Configure;Capture;Launcher;
 X-DBUS-StartupType=Unique
 X-DBUS-ServiceName=org.flameshot.Flameshot
-X-KDE-DBUS-Restricted-Interfaces=org_kde_kwin_effect-screenshot
+X-KDE-DBUS-Restricted-Interfaces=org.kde.kwin.Screenshot

 [Desktop Action Configure]
 Name=Configure

Sorry for the double post.

borgmanJeremy commented 3 years ago

Awesome, yes i will give this a try tonight and if it works get it in the 0.9 release.

hosiet commented 3 years ago

The proposed patch looks good except that we may need to use absolute path for both the basic Exec key and all [Actions] field.

Besides, I'm not sure if using absolute path would introduce any side effects for alternative packaging such as snap, flatpak, appimage etc. This will need some testing.

33Fraise33 commented 3 years ago

This does help but unfortunately I'm only able to cut out an image in one of my 2 displays. I also get a notification from Plasma Workspace: Screenshot saved to "/tmp/kwin_screenshot_xxxxxx" So it seems to screenshot natively first and then cutting from that?

EDIT: it does work correct when I launch it with xcb: QT_QPA_PLATFORM=xcb flameshot but it does only show one monitor available to clip when I: QT_QPA_PLATFORM=wayland flameshot gui

Here is a git diff of the changes I made. Could you try it out locally and let me know if this works for you?

diff --git a/data/desktopEntry/package/org.flameshot.Flameshot.desktop b/data/desktopEntry/package/org.flameshot.Flameshot.desktop
index a5308e3..eac291c 100644
--- a/data/desktopEntry/package/org.flameshot.Flameshot.desktop
+++ b/data/desktopEntry/package/org.flameshot.Flameshot.desktop
@@ -37,7 +37,7 @@ Keywords[nl_NL]=flameshot;schermfoto;screenshot;schermafdruk;vastleggen;schermop
 Keywords[es]=flameshot;screenshot;capture;shutter;captura;
 Keywords[de]=flameshot;screenshot;Bildschirmfoto;Aufnahme;
 Keywords[pt_BR]=flameshot;screenshot;captura de tela;captura;shutter;
-Exec=flameshot
+Exec=/usr/bin/flameshot
 Icon=org.flameshot.Flameshot
 Terminal=false
 Type=Application
@@ -46,7 +46,7 @@ StartupNotify=false
 Actions=Configure;Capture;Launcher;
 X-DBUS-StartupType=Unique
 X-DBUS-ServiceName=org.flameshot.Flameshot
-X-KDE-DBUS-Restricted-Interfaces=org_kde_kwin_effect-screenshot
+X-KDE-DBUS-Restricted-Interfaces=org.kde.kwin.Screenshot

 [Desktop Action Configure]
 Name=Configure

Sorry for the double post.

abhijeetviswa commented 3 years ago

Weirdly enough, the patch I provided works sporadically for me.

I was initially working on a cloned repo and had the .desktop file point to the debug build. After that, I installed Flameshot using the flameshot-git AUR package and tried making the same changes and it stopped working. I went back to using the debug build but it simply didn't work. I tried it again right now and it did. I'm really not sure what the problem is.

It would be nice if more people could test this out and report their findings.

33Fraise33 commented 3 years ago

Weirdly enough, the patch I provided works sporadically for me.

I was initially working on a cloned repo and had the .desktop file point to the debug build. After that, I installed Flameshot using the flameshot-git AUR package and tried making the same changes and it stopped working. I went back to using the debug build but it simply didn't work. I tried it again right now and it did. I'm really not sure what the problem is.

It would be nice if more people could test this out and report their findings.

I'm currently running the AUR git version with only the supplied desktop file change applied. But like supplied above I need to override the env variable for it to work correctly. Tested with 1, 2 and 3 screens in Wayland.

abhijeetviswa commented 3 years ago

I believe using xcb will allow you to only take screenshots of XWayland apps. I only have a single monitor, so I cannot test multi-monitor support on Wayland. Does it work with Spectacle?

33Fraise33 commented 3 years ago

I believe using xcb will allow you to only take screenshots of XWayland apps. I only have a single monitor, so I cannot test multi-monitor support on Wayland. Does it work with Spectacle?

spectacle works yes:

QT_QPA_PLATFORM=wayland spectacle
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
borgmanJeremy commented 3 years ago

I recently adjusted flameshot to always use XCB behind the scenes. This worked really well on all my gnome testing.

https://github.com/flameshot-org/flameshot/commit/ddd4eb5b0c51a6761179b8def628d1cd9a13599f

borgmanJeremy commented 3 years ago

Wow, its right in that PR, it only applies to gnome. Need to add KDE and test that with the desktop entry changes.

borgmanJeremy commented 3 years ago

Okay I think I know the problem.

After making the changes to the desktop file, you need to reboot your session. Then make sure you launch flameshot from the krunner menu and not the terminal. This makes it work for me every time.

dandv commented 3 years ago

I've made the change to X-KDE-DBUS-Restricted-Interfaces=org.kde.kwin.Screenshot, but screenshotting a region is only possible on my laptop monitor (I have an external monitor connected to it), and the upper 2 thirds of the laptop monitor gets covered by a grey rectangle.

I also get the notification that @33Fraise33 mentioned.

33Fraise33 commented 3 years ago

I've made the change to X-KDE-DBUS-Restricted-Interfaces=org.kde.kwin.Screenshot, but screenshotting a region is only possible on my laptop monitor (I have an external monitor connected to it), and the upper 2 thirds of the laptop monitor gets covered by a grey rectangle.

I also get the notification that @33Fraise33 mentioned.

do sudo pkill flameshot and start flameshot with QT_QPA_PLATFORM=xcb flameshot

For me that works on multiple monitors

All3xJ commented 3 years ago

I have the same problem, but with Xorg.

I can fix it doing this:

do sudo pkill flameshot and start flameshot with QT_QPA_PLATFORM=xcb flameshot

borgmanJeremy commented 3 years ago

@All3xJ Please open a separate issue for xorg, I want to keep this focused on wayland.

abhijeetviswa commented 3 years ago

Hi. Can I go ahead and make a PR for this?

borgmanJeremy commented 3 years ago

Yes please do

ghost commented 3 years ago

I still have this issue on plasma 5.22 and wayland on arch.

abhijeetviswa commented 3 years ago

I've switched back to X.org due to the lack of certain applications supporting screensharing. I still have the Wayland session installed and will try debugging this on 5.22 over the weekend.

mmahmoudian commented 3 years ago

@Toadfield the PR @abhijeetviswa kindly made was merged but it is not present in v0.9.0 and for the time being you only get it iff you install Flameshot either by compiling from source or the AUR to get the v0.10.0 . Would you please confirm if your have v0.10.0 installed.

ghost commented 3 years ago

I tried this and this package,are they not the newest version?

mmahmoudian commented 3 years ago

The first link is managed by us, but the second one is not even from this repo. For others to know, from AUR install flameshot-git to get the latest updates that are not released yet. The following is the link to the AUR that we maintain:

https://aur.archlinux.org/packages/flameshot-git

Also note that because we don't update the hash in the pkgbuild for every commit merged into master branch of this repo, your AUR manager might not automatically realise that there is a new version. You can always force it to install. For example with pamac you can run pamac install flameshot-git every few days to get the latest features and bug fixes.

DistantThunder commented 3 years ago

I confirm building from Git on Arch Linux, Flameshot works again on Wayland (or at least, KDE Wayland).

ghost commented 3 years ago

It works now.

abhijeetviswa commented 3 years ago

Closing this issues since this was fixed in 0.9.0

brightprogrammer commented 1 year ago

I've had the same problem after installing flameshot on EndeavourOS KDE. I installed some packages and restarted kde session. Problem was that grim wasn't able to load properly. Here's a screenshot of installed packages taken using flameshot :smile: flameshot-deps