Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work when using Plasma+Wayland #1380

Closed
abhijeetviswa opened this issue Feb 21, 2021 · 33 comments
Closed

Does not work when using Plasma+Wayland #1380

abhijeetviswa opened this issue Feb 21, 2021 · 33 comments
Assignees
Labels
Wayland Wayland specific issues

Comments

@abhijeetviswa
Copy link

abhijeetviswa commented Feb 21, 2021

Versions
Flameshot: 5b0bb50
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:

  • KWin requires you to use the D-Bus.
  • KWin enforces security by ensuring you have the X-KDE-DBUS-Restricted-Interfaces key with the value org.kde.kwin.Screenshot.
  • KWin uses something called KApplicationTrader to find the desktop file of the process and check if the aforementioned key exists. It compare the Exec key in the desktop files and the executable location obtained from procfs to do so.
  • Flameshot does not specify the full path to the binary in it's desktop file, unlike Spectacle.
  • Flameshot sets the X-KDE-DBUS-Restricted-Interfaces key to org_kde_kwin_effect-screenshot instead of org.kde.kwin.Screenshot.

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
Copy link
Contributor

What distro are you testing with?

@abhijeetviswa
Copy link
Author

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

@borgmanJeremy
Copy link
Contributor

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
Copy link
Contributor

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

@abhijeetviswa
Copy link
Author

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
Copy link
Contributor

Not sure how to do it safely either 😀

@abhijeetviswa
Copy link
Author

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

@abhijeetviswa
Copy link
Author

abhijeetviswa commented Feb 24, 2021

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
Copy link
Contributor

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

@hosiet
Copy link
Member

hosiet commented Feb 24, 2021

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
Copy link

33Fraise33 commented Feb 25, 2021

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Contributor

borgmanJeremy commented Feb 25, 2021

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

ddd4eb5

@borgmanJeremy
Copy link
Contributor

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

@borgmanJeremy
Copy link
Contributor

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
Copy link
Contributor

dandv commented Mar 1, 2021

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
Copy link

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
Copy link

All3xJ commented Mar 2, 2021

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
Copy link
Contributor

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

@mmahmoudian mmahmoudian added the Wayland Wayland specific issues label Mar 3, 2021
@abhijeetviswa
Copy link
Author

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

@borgmanJeremy
Copy link
Contributor

Yes please do

@ghost
Copy link

ghost commented Jun 11, 2021

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

@abhijeetviswa
Copy link
Author

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
Copy link
Member

@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
Copy link

ghost commented Jun 13, 2021

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

@mmahmoudian
Copy link
Member

mmahmoudian commented Jun 14, 2021

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
Copy link

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

@ghost
Copy link

ghost commented Jun 14, 2021

It works now.

@abhijeetviswa
Copy link
Author

Closing this issues since this was fixed in 0.9.0

@brightprogrammer
Copy link

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 😄
flameshot-deps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Wayland Wayland specific issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants