flameshot icon indicating copy to clipboard operation
flameshot copied to clipboard

GNOME custom "flameshot gui" keybinding doesn't work with Wayland, command works from terminal, nothing in dbus-monitor output either way

Open jikamens opened this issue 10 months ago • 54 comments

Flameshot Version

I've tried this with both the Flameshot 12.1.0 included in Debian and with Flameshot built from current git (a7e0a6187e7004ac4f4065f3542dbecc5ed726d9)

Installation Type

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

Operating System type and version

Tried both Debian 12 + Debian 13 testing

Description

I have a custom key binding set to execute "flameshot gui".

When I run the command "flameshot gui" from the command line, it works just fine.

When I hit the custom key binding, I see from my process listing that there's a flameshot gui process running, but nothing happens.

This happens with both the flameshot that comes with Debian and the one I built myself. It happens with Debian Trixie Testing and I think also with Debian 12 Bookworm, although I can't go backwards to Bookworm to confirm.

I run dbus-monitor as instructed https://flameshot.org/docs/guide/troubleshooting/ and it doesn't show any messages being sent by Flameshot when I execute "flameshot gui" either from the command line or with the key bindings.

This is not #325 because I'm not specifying any arguments to "flameshot gui".

Steps to reproduce

No response

Screenshots or screen recordings

No response

System Information

Debian Trixie Testing amd_64 GNOME Wayland. Dual monitors via DisplayLink.

jikamens avatar Sep 05 '23 13:09 jikamens

Tested after changing monitor scaling from 125% to 100%: didn't make a difference.

Tested with my built-in laptop screen with no DisplayLink: didn't make a difference.

Tested with Xorg instead of Wayland: WORKS FINE.

jikamens avatar Sep 05 '23 13:09 jikamens

OK, so it's weirder than this.

If I log into Wayland, and I have Flameshot configured to launch on startup, then that flameshot can't take screenshots either, i.e., when I click on the icon and select "Take Screenshot" nothing happens. But if I kill that flameshot and restart it by running it from the terminal, then THAT flameshot can take screenshots.

So the common factor between the two is flameshot launched from inside my login session by me works, flameshot launched in the background, on startup or from a key binding, doesn't.

I've captured wrapped flameshot in a script to capture what environment variables are set in each case and tried to eliminate the differences to see if that would make a difference, but I was unable to identify any environment variables that are relevant.

Bizarre.

jikamens avatar Sep 05 '23 13:09 jikamens

I had to change to XORG to workaround this

it's real pain

I've tried the following keybinding -> doesn't work

ALT+F2 prompt to trigger it flameshot gui -> doesn't work

terminal command -> works

username0136 avatar Sep 07 '23 12:09 username0136

I noticed the same thing with the keybinding not working in recent releases on X11. I ran "flameshot gui" from the console and got a segmentation fault, which explains the problem. Starting the app and clicking the tray icon still works fine.

3vi1 avatar Oct 02 '23 17:10 3vi1

I noticed the same thing with the keybinding not working in recent releases on X11. I ran "flameshot gui" from the console and got a segmentation fault, which explains the problem. Starting the app and clicking the tray icon still works fine.

This is not the same issue and you should probably open a separate ticket for it rather than commenting about it on this issue.

jikamens avatar Oct 03 '23 11:10 jikamens

It does work for me on Fedora 38 and Gnome 44. Curiously, the tray menu option "Take Screenshot" does not work for me and I get an "Unable to capture screen" notification...

image

image

johlandabee avatar Oct 04 '23 15:10 johlandabee

Hi, I have the same problem on my archlinux. I have tested with the DBus as indicated and got this:

dbus-monitor --session sender=org.flameshot.Flameshot
signal time=1696522089.344296 sender=org.freedesktop.DBus -> destination=:1.1140 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.1140"
signal time=1696522089.344331 sender=org.freedesktop.DBus -> destination=:1.1140 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.1140"
method call time=1696522119.590394 sender=:1.1142 -> destination=org.freedesktop.DBus serial=13 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.a11y.Bus',arg1=''"
method call time=1696522119.590529 sender=:1.1142 -> destination=org.freedesktop.DBus serial=14 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameHasOwner
   string "org.a11y.Bus"
method call time=1696522119.590768 sender=:1.1142 -> destination=org.freedesktop.DBus serial=15 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.a11y.Bus'"
method call time=1696522119.590850 sender=:1.1142 -> destination=org.freedesktop.DBus serial=16 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.a11y.Bus"
method call time=1696522119.591081 sender=:1.1142 -> destination=org.a11y.Bus serial=17 path=/org/a11y/bus; interface=org.freedesktop.DBus.Properties; member=Get
   string "org.a11y.Status"
   string "ScreenReaderEnabled"
method call time=1696522119.591634 sender=:1.1142 -> destination=org.a11y.Bus serial=18 path=/org/a11y/bus; interface=org.freedesktop.DBus.Properties; member=Get
   string "org.a11y.Status"
   string "IsEnabled"

multisme avatar Oct 05 '23 16:10 multisme

It's stopped working since upgrading xdg-desktop-portal to 1.17. According to discussion on x-d-p github, apparently previously it was working because of a bug in pre-1.17 which allowed to run flameshot this way and probably because of a bug in flameshot https://github.com/flatpak/xdg-desktop-portal/issues/1070

AFAIU probably x-d-p fixed the bug but it's now flameshot's time to fix it's bug.

darkblaze69 avatar Oct 06 '23 17:10 darkblaze69

Likely relevant lines in syslog:

2023-10-06T13:17:32.816700-07:00 matz xdg-desktop-por[3231]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2023-10-06T13:17:32.823643-07:00 matz flameshot[172014]: flameshot: error: Unable to capture screen
2023-10-06T13:17:32.827157-07:00 matz flameshot[172014]: flameshot: error: Unable to capture screen
2023-10-06T13:17:32.828006-07:00 matz dbus-daemon[2451]: [session uid=1000 pid=2451] Activating via systemd: service name='org.freedesktop.Tracker3.Miner.Extract' unit='tracker-extract-3.service' requested by ':1.88' (uid=1000 pid=3250 comm="/usr/libexec/tracker-miner-fs-3")
2023-10-06T13:17:32.853925-07:00 matz systemd[2407]: Starting tracker-extract-3.service - Tracker metadata extractor...
2023-10-06T13:17:32.865351-07:00 matz flameshot[172014]: flameshot: info: Screenshot aborted.
2023-10-06T13:17:32.896398-07:00 matz dbus-daemon[2451]: [session uid=1000 pid=2451] Successfully activated service 'org.freedesktop.Tracker3.Miner.Extract'
2023-10-06T13:17:32.896596-07:00 matz systemd[2407]: Started tracker-extract-3.service - Tracker metadata extractor.

ha1dfo avatar Oct 06 '23 20:10 ha1dfo

I also appear to have the same issue. This occurs with both an upgrade from Ubuntu 23.04 to 23.10 and also a fresh install of Ubuntu 23.10 too.

The work around I found was to make a copy of the org.flameshot.Flameshot.desktop file in ~/.local/shared/applications, and set the Exec in [Desktop Entry] as Exec=xterm -iconic -e flameshot gui --delay 500

after installing xterm.

This allows me a single click on the app icon to create screenshots without error.

dwoodwar03 avatar Oct 14 '23 23:10 dwoodwar03

Same here; I have Ubuntu 23.10 fresh installed. Flameshot from apt Installed: 12.1.0-2

Logs:

If I press "take screenshot" from the flameshot menu.

2023-10-15T22:12:29.800424+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: flameshot: error: Unable to capture screen
2023-10-15T22:12:39.141604+02:00 olof-hp xdg-desktop-por[2676]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2023-10-15T22:12:39.159940+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: flameshot: error: Unable to capture screen

And if I "open launcher" from the menu

2023-10-15T22:14:20.243663+02:00 olof-hp xdg-desktop-por[2676]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2023-10-15T22:14:20.254265+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: flameshot: error: Unable to capture screen
2023-10-15T22:14:20.254369+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: QPixmap::scaled: Pixmap is a null pixmap
2023-10-15T22:14:20.256524+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: QPixmap::scaled: Pixmap is a null pixmap
2023-10-15T22:14:20.266799+02:00 olof-hp gnome-shell[2424]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x800008 specified for 0x800011.
2023-10-15T22:14:20.306161+02:00 olof-hp gnome-shell[2424]: Meta.Rectangle is deprecated, use Mtk.Rectangle instead
2023-10-15T22:14:27.912773+02:00 olof-hp gnome-shell[2424]: message repeated 101 times: [ Meta.Rectangle is deprecated, use Mtk.Rectangle instead]
2023-10-15T22:14:29.309784+02:00 olof-hp xdg-desktop-por[2676]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2023-10-15T22:14:29.326905+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: flameshot: error: Unable to capture screen
2023-10-15T22:14:29.408036+02:00 olof-hp org.flameshot.Flameshot.desktop[6057]: flameshot: error: Unable to capture screen
2023-10-15T22:14:29.435635+02:00 olof-hp gnome-shell[2424]: Window manager warning: Invalid WM_TRANSIENT_FOR window 0x800008 specified for 0x800011.
2023-10-15T22:14:29.460419+02:00 olof-hp gnome-shell[2424]: Meta.Rectangle is deprecated, use Mtk.Rectangle instead

sliddjur avatar Oct 15 '23 20:10 sliddjur

Same here on Ubuntu 23.10. Works only if i start flameshot gui in a gnome-terminal.

Tests: Start "flameshot gui" with Alt+F2 => unable to capture screen Start "flameshot gui" in gnome-terminal or kgx => everything works like expected Start "flameshot" in "App menue" (Meta-key) => can't create screenshot with the icon in the top bar Start "flameshot" in gnome-terminal or kgx => everything works like expected

Gnome 45 on Wayland.

devaux avatar Oct 16 '23 09:10 devaux

I have the same troubles with Manjaro and Gnome 44.5

VladyslavParashchenko avatar Oct 18 '23 11:10 VladyslavParashchenko

I have the same troubles with Fedora 39 and Gnome 45

systemd[42073]: Started app-gnome-flameshot-885317.scope - Application launched by gsd-media-keys.
xdg-desktop-por[584367]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
flameshot[885317]: flameshot: error: Unable to capture screen
flameshot[885317]: flameshot: error: Unable to capture screen
flameshot[885317]: flameshot: info: Screenshot aborted.

same problem https://github.com/flatpak/xdg-desktop-portal/issues/1070

I got the workaround now:

https://github.com/flatpak/xdg-desktop-portal/issues/1070#issuecomment-1771302632

ttys3 avatar Oct 19 '23 15:10 ttys3

Hi, same problem here on Ubuntu 23.10, Gnome 45, Wayland and Flameshot 12.1.0 : the program automatically starts with computer session - if I try to launch it from the top menu, nothing happens.

If I close it and re-lauch from terminal, it works - like other said. But in my case, sometimes, when I run the "Screenshot" row, screen freezes - mouse is not visible anymore, nothing works with Alt + Tab, and I have to manually reset…

Valeryan24 avatar Oct 27 '23 18:10 Valeryan24

Same here on Ubuntu 23.10. Works only if i start flameshot gui in a gnome-terminal.

Tests: Start "flameshot gui" with Alt+F2 => unable to capture screen Start "flameshot gui" in gnome-terminal or kgx => everything works like expected Start "flameshot" in "App menue" (Meta-key) => can't create screenshot with the icon in the top bar Start "flameshot" in gnome-terminal or kgx => everything works like expected

Gnome 45 on Wayland.

I found that Using Alt F2 I can run: sh -c -- "flameshot gui" And it works.

Also Alt F2 I can run: sh -c -- flameshot And it adds a usuable icon in the system tray.

dwoodwar03 avatar Oct 31 '23 22:10 dwoodwar03

@dwoodwar03 I can confirm this. It even works with the hotkeys!

2023-10-31_15-24

ha1dfo avatar Oct 31 '23 22:10 ha1dfo

Same here on Ubuntu 23.10. Works only if i start flameshot gui in a gnome-terminal. Tests: Start "flameshot gui" with Alt+F2 => unable to capture screen Start "flameshot gui" in gnome-terminal or kgx => everything works like expected Start "flameshot" in "App menue" (Meta-key) => can't create screenshot with the icon in the top bar Start "flameshot" in gnome-terminal or kgx => everything works like expected Gnome 45 on Wayland.

I found that Using Alt F2 I can run: sh -c -- "flameshot gui" And it works.

Also Alt F2 I can run: sh -c -- flameshot And it adds a usuable icon in the system tray.

this will not work. I tried under Wayland.

bash -c -- "flameshot gui"

result in the same error:

Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
flameshot: error: Unable to capture screen
flameshot: info: Screenshot aborted.

but this will work:

https://github.com/flatpak/xdg-desktop-portal/issues/1070#issuecomment-1788441001

sudo tee /usr/local/bin/flameshot-gui-workaround > /dev/null <<'EOF'
#!/bin/bash
flameshot gui

EOF

sudo chmod a+x /usr/local/bin/flameshot-gui-workaround

make call to the wrapper /usr/local/bin/flameshot-gui-workaround

ttys3 avatar Nov 01 '23 05:11 ttys3

but this will work:

flatpak/xdg-desktop-portal#1070 (comment)

sudo tee /usr/local/bin/flameshot-gui-workaround > /dev/null <<'EOF'
#!/bin/bash
flameshot gui

EOF

sudo chmod a+x /usr/local/bin/flameshot-gui-workaround

make call to the wrapper /usr/local/bin/flameshot-gui-workaround

Can confirm above worked on Wayland, Gnome and Ubuntu 23.10 :point_up:

sudo tee /usr/local/bin/flameshot-workaround > /dev/null <<'EOF'
#!/bin/bash
flameshot

EOF

sudo chmod a+x /usr/local/bin/flameshot-workaround

This also launches a working flameshot to the gnome tray at login. image

sliddjur avatar Nov 01 '23 11:11 sliddjur

I found that Using Alt F2 I can run: sh -c -- "flameshot gui" And it works. Also Alt F2 I can run: sh -c -- flameshot And it adds a usuable icon in the system tray.

this will not work. I tried under Wayland.

bash -c -- "flameshot gui"

sh -c -- "flameshot gui" works normally here, both in a custom shortcut as well as in "Alt+F2", but bash ... doesn't. Did you try with sh or other shell (zsh, etc)?

jrom99 avatar Nov 01 '23 16:11 jrom99

@jrom99 no. non of the shell works.

bash, sh, zsh

Wayland user.

ttys3 avatar Nov 02 '23 02:11 ttys3

wayland user (ubuntu 23.10),

sh works zsh,bash not

kamil-karkus avatar Nov 02 '23 10:11 kamil-karkus

sh -c -- "flameshot gui"

sh is just an symlink.

for Fedora, it is actually linked to bash

❯ ls -l `which sh`                                                                                                           
lrwxrwxrwx root root 4 B Wed Jul 19 00:00:00 2023  /usr/bin/sh ⇒ bash

For Ubuntu users, it is linked to dash, not bash

ttys3 avatar Nov 02 '23 16:11 ttys3

sh -c -- "flameshot gui"

sh is just an symlink.

for Fedora, it is actually linked to bash

❯ ls -l `which sh`                                                                                                           
lrwxrwxrwx root root 4 B Wed Jul 19 00:00:00 2023  /usr/bin/sh ⇒ bash

For Ubuntu users, it is linked to dash, not bash

It doesn't matter that it's a symlink, since the problem seems to be how, in Wayland, Flameshot is refused screen access since its ID doesn't match its .desktop file. I think using a file/command/alias helps because it doesn't need a .desktop file (or Flameshot is launched with another name from them).

jrom99 avatar Nov 02 '23 21:11 jrom99

Hello everyone, I had the same issue.

System information:

  • Ubuntu 23.10
  • Gnome 45
  • Linux 6.5.0.13

If I entered flameshot gui in the terminal, I was able to take a screenshot with Flameshot. If I entered the Print key as shortcut for flameshot gui, the following error messages occured in the journal

xdg-desktop-por[3852]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog flameshot[32110]: flameshot: error: Unable to capture screen

To fix the issue, I created the following script and set the Print key as the shortcut for /path/to/script/run_flameshot.sh.

#!/usr/bin/env bash                                                             
flameshot gui

If I type Print, the script will run and I can take a screenshot with Flameshot.

Disabling Wayland in /etc/gdm3/custom.conf also worked for me, too. However, after disabling Wayland, I could no longer copy screenshots in Emacs (it uses wl_clipboard). So this was not a workaround for me.

I am happy to use Flameshot and thank the Flameshot team for this great application.

martin-schell avatar Nov 25 '23 14:11 martin-schell

https://github.com/flameshot-org/flameshot/issues/3326#issuecomment-1789267986

@jrom99 no. non of the shell works.

bash, sh, zsh

Wayland user.

no shell works for me either - Fedora 39, Gnome 45.1 (wayland)

Linux jvh-machine 6.5.12-300.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Nov 20 22:44:24 UTC 2023 x86_64 GNU/Linux

vanheck avatar Nov 28 '23 08:11 vanheck

I found a proper way to solve this issue temporarily(maybe only need to run once):

flatpak permission-set screenshot screenshot flameshot yes

We can confirm that this issue is caused by the system screenshot permission check. So we only need to add the flameshot application to the allowed list. The application ID of the custom shortcut is just the flameshot. You can also run the command below to fix the take a screenshot by click the flameshot icon in the top bar:

flatpak permission-set screenshot screenshot org.flameshot.Flameshot yes

And, check the screenshot permissions by the command below:

flatpak permissions

image

---- called by the custom shortcut.

@mmahmoudian Can you help to write the actions required by the user in the application or just run these commands silently(I'm not sure if it violates the security rules)?

nooop3 avatar Dec 02 '23 18:12 nooop3

@nooop3 great! This is finally the fix. By the way does clipboard works for you? The result cannot be pasted for me in wayland, I have wl-clipboard, grim in GNOME.

darkblaze69 avatar Dec 02 '23 19:12 darkblaze69

@nooop3 great! This is finally the fix. By the way does clipboard works for you? The result cannot be pasted for me in wayland, I have wl-clipboard, grim in GNOME.

@darkblaze69 I can paste the screenshot by clipboard. I don't install the wl-clipboard, grim in GNOME, only xclip. Even when I uninstall the xclip, the clipboard still works. I have no idea about the wl-clipboard/grim. Can you make sure you have installed the xdg-desktop-portal-gnome?

nooop3 avatar Dec 03 '23 12:12 nooop3

Ok, got it. I'm trying to use in Wayland-only session without Xwayland, so xclip not relevant here. Apparently clipboard on flameshot is broken also in pure Wayland.

darkblaze69 avatar Dec 03 '23 12:12 darkblaze69