flameshot icon indicating copy to clipboard operation
flameshot copied to clipboard

Flameshot unable to capture screen when triggered through Gnome shortcut

Open kekonn opened this issue 2 years ago • 161 comments

Flameshot Version

Flameshot v12.1.0 (-) Compiled with Qt 5.15.10

Installation Type

Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)

Operating System type and version

Arch with kernel 6.5.4-273-tkg-bore

Description

When using a shortcut (Print screen) to run Flameshot I get "Unable to capture screen".

When I run the command from the shortcut in a terminal, it works.

Now both used to work fine before, but stopped working after my daily updates sometime this week. The normal Gnome screenshot program still works.

If you can tell me where I should look for further logs, please do, so I can upload them.

Steps to reproduce

In Arch running Gnome:

  1. Bind screenshot a region key to printscreen and set it to /usr/bin/flameshot gui
  2. Use key to trigger flameshot
  3. Get Unable to capture screen error

Screenshots or screen recordings

image (Shortcut settings)

System Information

System:
  Host: tuxgamer Kernel: 6.5.4-273-tkg-bore arch: x86_64 bits: 64
    Desktop: GNOME v: 44.5 Distro: Arch Linux
Graphics:
  Device-1: AMD Navi 22 [Radeon RX 6700/6700 XT/6750 XT / 6800M/6850M XT]
    driver: amdgpu v: kernel
  Device-2: Logitech Brio 500 driver: hid-generic,usbhid,uvcvideo type: USB
  Device-3: Chicony USB2.0 FHD UVC WebCam driver: uvcvideo type: USB
  Display: wayland server: X.org v: 1.21.1.8 with: Xwayland v: 23.2.1
    compositor: gnome-shell driver: X: loaded: modesetting dri: radeonsi
    gpu: amdgpu resolution: 5120x1440~60Hz
  API: EGL v: 1.5 drivers: kms_swrast,radeonsi,swrast
    platforms: gbm,wayland,x11,surfaceless,device
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 23.2.1-arch1.2
    renderer: AMD Radeon RX 6700 XT (navi22 LLVM 16.0.6 DRM 3.54
    6.5.4-273-tkg-bore)

kekonn avatar Oct 07 '23 06:10 kekonn

I have exactly the same problem. I use Flameshot on Arch and it stopped working after my routine updates.

nickuc avatar Oct 07 '23 06:10 nickuc

does it launch or log anything when you do this command on the terminal? flameshot gui

I am on arch too, 6.5.5-arch1-1 it does work on my side, however due to gnome experimental fractional scaling, the window does open in the wrong places and block the places that I am trying to screenshot

I have a feeling that this could be a wayland issue

OK, that's interesting, actually I have stopped using the AUR flameshot-git, I have installed flameshot through official arch repos (they didn't have this before) and it started working without fractional scaling issue or any other issues. There is a warning that you should be solving for consistent usage, please set QT_QPA_PLATFORM=wayland

image

mrwormhole avatar Oct 08 '23 06:10 mrwormhole

does it launch or log anything when you do this command on the terminal? flameshot gui

It does.

I am on arch too, 6.5.5-arch1-1 it does work on my side, however due to gnome experimental fractional scaling, the window does open in the wrong places and block the places that I am trying to screenshot

I have a feeling that this could be a wayland issue

OK, that's interesting, actually I have stopped using the AUR flameshot-git, I have installed flameshot through official arch repos (they didn't have this before) and it started working without fractional scaling issue or any other issues. There is a warning that you should be solving for consistent usage, please set QT_QPA_PLATFORM=wayland

image

I want to point out that flameshot gui works from the terminal wether QT_QPA_PLATFORM is set or not. It's when I use the tray icon or through a gnome shortcut that there is an issue.

I am starting to suspect that something in my Gnome desktop updated and broke an assumption of Flameshot. Is there a way to enable debug logging to get more info about the error Flameshot produces?

kekonn avatar Oct 08 '23 07:10 kekonn

can you delete the package that you installed from AUR and install the official one? (extra/flameshot)

mrwormhole avatar Oct 08 '23 08:10 mrwormhole

I did not install through the AUR: image

kekonn avatar Oct 08 '23 09:10 kekonn

Thanks for the issue and also thank you @mrwormhole for the comments. I think I should mention few points:

  1. the AUR package flameshot-git is actually maintained by us. Therefore it is "official", but it is always compiling aganst the HEAD of the master branch of this git repo, therefore you should consider it as beta, and not stable release.
  2. At the moment we have regression bug in the HEAD of master that makes the flameshot gui to cause segfault. We are aware of it and it is getting worked on.
  3. Gnome constantly change their API, which always put devs in disadvantage. That said, this issue might not be Gnome-specific.

I am not a Gnome user, so I cannot right-away confirm this. I will try to reproduce the issue in a VM later and see if it is reproducible in a clean-install VM. in the meantime, perhaps you can use the AppImage while we are investigating :)

mmahmoudian avatar Oct 08 '23 11:10 mmahmoudian

Is there anything I can do to help, such as gather debug logs? I tried to look in the settings, but couldn't find anything about debug logging.

kekonn avatar Oct 08 '23 12:10 kekonn

@kekonn Thanks, but unfortunately we do not have extensive log reporting. Flameshot was very stable until Gnome Wayland hit the market and then many things went wrong and we are having hard time to keep up. The best help you can do is to install Arch + Gnome Wayland on a VM (no other software), and then install Flameshot and see if flameshot gui works there or not. I personally don't have access to a computer with enough empty disk space to try to reproduce this.

Also, please edit your original post and change the Installation type to Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...) because you have installed Flameshot from the extra repo of Arch rather than AUR.

mmahmoudian avatar Oct 08 '23 12:10 mmahmoudian

Also, please edit your original post and change the Installation type to Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...) because you have installed Flameshot from the extra repo of Arch rather than AUR.

Done! I also want to mention that running flameshot gui from the terminal does work for me. The issue is that that is the only way to make it work.

The Gnome shortcut and tray icon method are the ones that broke sometime in the last week. I will also try to see if the appimage improves the situation.

EDIT: The AppImage throws the following error and does not work at all:

~/Applications 
❯ ./Flameshot-12.1.0.x86_64_10ab227368a704f2d66cded7a7aa8248.AppImage 
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
execv error: No such file or directory

kekonn avatar Oct 08 '23 12:10 kekonn

Same as @kekonn, it works for me from the terminal. Using a shortcut from Gnome, I see in the system logs:

oct 09 10:26:55 t14 flameshot[2895]: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
oct 09 10:26:55 t14 systemd[1272]: Started Application launched by gsd-media-keys.
oct 09 10:26:55 t14 xdg-desktop-por[1889]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
oct 09 10:26:55 t14 flameshot[2895]: flameshot: error: Unable to capture screen
oct 09 10:26:55 t14 flameshot[2895]: flameshot: error: Unable to capture screen
oct 09 10:26:55 t14 flameshot[2895]: flameshot: info: Screenshot aborted.

Worth to mention that Flameshot was working just fine as of version 12.0.1-2 and stopped working in 12.0.1-3.

emystein avatar Oct 09 '23 13:10 emystein

Same here. Launching via terminal works as expected (I only have a warning but I don't know if he did it before)

flameshot gui
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.

Using Gnome shortcuts (PRINT with /usr/bin/flameshot gui) gives me "Unable to capture screen"

Flameshot v12.1.0 (001726a5)
Compiled with Qt 5.15.5

OS: EndeavourOS
Kernel: x86_64 Linux 6.5.5-arch1-1
DE: GNOME 44.4
WM: Mutter

friimaind avatar Oct 09 '23 14:10 friimaind

https://github.com/search?q=repo%3Aflameshot-org%2Fflameshot+GDBus.Error%3Aorg.freedesktop.DBus.Error.AccessDenied&type=issues

aren't these all related?

pschichtel avatar Oct 10 '23 00:10 pschichtel

Same issue came to me after upgrading my manjaro(gnome DE) today, only terminal command or right click on tray icon worked!

qomosoloto avatar Oct 10 '23 07:10 qomosoloto

@qomosoloto

only terminal command or right click on tray icon worked!

Then what doesn't work? These two are the only two ways you can trigger Flameshot.

mmahmoudian avatar Oct 10 '23 08:10 mmahmoudian

For me only the terminal method works, but the method that stopped working for all of us is triggering it through Gnome Shortcuts.

kekonn avatar Oct 10 '23 08:10 kekonn

Reproduced on latest Arch with GNOME.

flameshot gui from gnome-terminal works fine, but the exact same command doesn't work from the launcher (i.e. Alt+F2).

ghost avatar Oct 10 '23 09:10 ghost

Ah wait, I should've installed the AUR version, previous comment is for flameshot from the official extra repo.

I'll test with the AUR version when I get the chance.

ghost avatar Oct 10 '23 09:10 ghost

Same problem with flameshot-git from AUR.

ghost avatar Oct 10 '23 15:10 ghost

after some testing I found: https://github.com/flatpak/xdg-desktop-portal/issues/1070

I quick workaround is: copy your /usr/share/applications/org.flameshot.Flameshot.desktop file to ~/.local/share/applications/flameshot.desktop. xdg-desktop-portal is than able to properly find the application and asks for permissions and/or allows the screenshot. You can delete the new desktop file right after you granted permissions.

Alternatively a downgrade of the xdg-desktop-portal binary might also work.

@mmahmoudian From that issue, this summary comment seems relevant to you/flameshot: https://github.com/flatpak/xdg-desktop-portal/issues/1070

specifically:

And lastly, the error message you're seeing is on purpose. Flameshot needs to create a window before using the portal. You should also open an issue on their bug tracker.

pschichtel avatar Oct 10 '23 18:10 pschichtel

I quick workaround is: copy your /usr/share/applications/org.flameshot.Flameshot.desktop file to ~/.local/share/applications/flameshot.desktop.

For me this doesn't help, also tried on the new user.

We can debug some via xdg-desktop-portal --replace --verbose In XDP 1.6.0 it was indeed its bug which allowed flameshot to run to permission request and so forth:

XDP: Assigning app ID "" to pid 55633 which has unit "app-gnome-flameshot-55633.scope"
XDP: Handle Screenshot
XDP: No 'screenshot' permissions found: No entry for screenshot
XDP: Calling Screenshot with interactive=0
XDP: sending response: 0

The ID is empty because of XDP bug, it says 'no permission found' though request was shown and I allowed it and all good.

Since XDP 1.7.0 the matching bug was fixed, now it's able to match the ID, but the permission request isn't called:

XDP: Assigning app ID "flameshot" to pid 64571 which has unit "app-gnome-flameshot-64571.scope"
XDP: Handle Screenshot
XDP: No permissions stored for: screenshot screenshot, app flameshot

(/usr/lib/xdg-desktop-portal:64541): xdg-desktop-portal-WARNING **: 02:03:49.117: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
XDP: sending response: 2

So just by guessing based on the output the probable solution would be to create some small window on flameshot gui ?

darkblaze69 avatar Oct 10 '23 21:10 darkblaze69

yeah I just repeated it on a different system. You actually have to start the application and take a screenshot while the configuration window is focused. It should then ask for permissions.

pschichtel avatar Oct 10 '23 21:10 pschichtel

I quick workaround is: copy your /usr/share/applications/org.flameshot.Flameshot.desktop file to ~/.local/share/applications/flameshot.desktop.

Still not working.

chuxinyuan avatar Oct 10 '23 21:10 chuxinyuan

@qomosoloto

only terminal command or right click on tray icon worked!

Then what doesn't work? These two are the only two ways you can trigger Flameshot.

You can also trigger flameshot by using a custom keyboard shortcut to activate that terminal command, i.e. setting flameshot gui to activate when you press the Print Screen key or a key combination like Ctrl + Print Screen. The problem that multiple people (including me) are having is that we are not able to trigger Flameshot using a keyboard shortcut set via GNOME settings.

Tobleh avatar Oct 10 '23 23:10 Tobleh

I have exactly the same problem.but in terminal is ok.

Cyber-SiKu avatar Oct 11 '23 10:10 Cyber-SiKu

yeah I just repeated it on a different system. You actually have to start the application and take a screenshot while the configuration window is focused. It should then ask for permissions.

This works for me, but only when taking screenshots via the tray icon. So to recap:

  • flameshot gui from the terminal: works
  • Take Screenshot from the tray icon: works if running the workaround above (copy the desktop file, open flameshot configuration from the tray icon, take screenshot from the tray icon with the configuration open, grant permission)
  • Shortcut mapped to flameshot gui: does not work

gianmarcotoso avatar Oct 11 '23 12:10 gianmarcotoso

@gianmarcotoso

  • flameshot gui from the terminal: works
  • ...
  • Shortcut mapped to flameshot gui: does not work

This is weird. Isn't the Gnome shortcut suppose to start a shell and run the command (in this case flameshot gui) there?

What happens if you change the Gnome shortcut to bash -c "flameshot gui" and see if that changes anything?

mmahmoudian avatar Oct 11 '23 14:10 mmahmoudian

@mmahmoudian it's extremely weird.

Isn't the Gnome shortcut suppose to start a shell and run the command (in this case flameshot gui) there? What happens if you change the Gnome shortcut to bash -c "flameshot gui" and see if that changes anything?

I had the same intuition and actually tried that, same result: "Unable to capture screen". I've also tried to modify the flameshot.desktop file, setting the launch command to flameshot gui, and then mapping the shortcut to gtk-launch flameshot.desktop: same result.

I suspect it has something to do with how Gnome handles permission, but I can't really be sure as I can't find any logs anywhere. Do you have any suggestion as to how this can be debugged?

gianmarcotoso avatar Oct 11 '23 15:10 gianmarcotoso

Worth to mention that Flameshot was working just fine as of version 12.0.1-2 and stopped working in 12.0.1-3.

Unrelated, tried downgrading just for the sake of it.

Bitals avatar Oct 11 '23 16:10 Bitals

What happens if you change the Gnome shortcut to bash -c "flameshot gui" and see if that changes anything?

unfortunately does not work for me

Tealk avatar Oct 11 '23 16:10 Tealk

Using argos script on Gnome as a workaround:

filename: ~/.config/argos/flameshot.sh

#!/usr/bin/env bash

echo "flameshot"
echo "---"
echo "take screenshot | bash='flameshot gui' terminal=false"

This creates a shortcut for flameshot on Gnome's top bar. Invoking flameshot from this shortcut works normally

fabiojb avatar Oct 11 '23 16:10 fabiojb

using wrapper like /usr/local/bin/flameshot-gui allows to use as shortcut:

#!/bin/bash
/usr/bin/flameshot gui

But paste after screenshoting doesn't work.

darkblaze69 avatar Oct 11 '23 16:10 darkblaze69