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

flameshot with Gnome 44 and wayland working only in specific setting #3213

Open
manfredlotz opened this issue May 29, 2023 · 83 comments
Open
Labels
High Priority Unconfirmed Bug The bug is not confirmed by anyone else. Wayland Wayland specific issues

Comments

@manfredlotz
Copy link

Flameshot Version

This is EndeavourOS with Gnome 44 and Wayland. flameshot is 12.1.0-1

Flameshot v12.1.0 (-)
Compiled with Qt 5.15.5
linux: 6.3.4-zen1-1-zen
endeavouros: unknown

Installation Type

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

Operating System type and version

Linux, 6.3.4-zen

Description

As I was unable to get a screenshot with flameshot I copied /usr/share/applications/org.flameshot.Flameshot.desktop
to ~/.local/share/applications/org.flameshot.Flameshot.desktop

Then I changed the exec line to

Exec=env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland /usr/bin/flameshot

flameshot starts ok but screenshot not working

I ran dbus-monitor --session sender=org.flameshot.Flameshot and got

method call time=1685385145.732791 sender=:1.314 -> destination=org.freedesktop.portal.Desktop serial=30 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "e439ac62bf72498fb8b3c67a00fd9c88"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]

But when I create a script ~/bin/flameshot.sh containing

#! /bin/sh

env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland /usr/bin/flameshot

then flameshot starts ok and screenshot is working fine

Here the dbus-monitor shows

method call time=1685385248.149252 sender=:1.354 -> destination=org.freedesktop.DBus serial=31 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.freedesktop.portal.Desktop'"
method call time=1685385248.149292 sender=:1.354 -> destination=org.freedesktop.DBus serial=32 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1685385248.149642 sender=:1.354 -> destination=org.freedesktop.DBus serial=33 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1685385248.149939 sender=:1.354 -> destination=org.freedesktop.DBus serial=34 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',path='/org/freedesktop/portal/desktop/request/1_354/0617ee6d667a4d04afbeb06e5c7962cd',interface='org.freedesktop.portal.Request',member='Response'"
method call time=1685385248.149957 sender=:1.354 -> destination=org.freedesktop.DBus serial=35 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.freedesktop.portal.Desktop'"
method call time=1685385248.149966 sender=:1.354 -> destination=org.freedesktop.DBus serial=36 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1685385248.150206 sender=:1.354 -> destination=org.freedesktop.portal.Desktop serial=37 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "0617ee6d667a4d04afbeb06e5c7962cd"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]
method call time=1685385248.695167 sender=:1.354 -> destination=org.freedesktop.portal.Desktop serial=38 path=/org/freedesktop/portal/desktop/request/1_354/0617ee6d667a4d04afbeb06e5c7962cd; interface=org.freedesktop.portal.Request; member=Close
method call time=1685385248.696921 sender=:1.354 -> destination=org.freedesktop.DBus serial=39 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',path='/org/freedesktop/portal/desktop/request/1_354/0617ee6d667a4d04afbeb06e5c7962cd',interface='org.freedesktop.portal.Request',member='Response'"
method call time=1685385248.696945 sender=:1.354 -> destination=org.freedesktop.DBus serial=40 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.portal.Desktop'"
method call time=1685385248.696954 sender=:1.354 -> destination=org.freedesktop.DBus serial=41 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.portal.Desktop'"
method call time=1685385252.688376 sender=:1.354 -> destination=org.freedesktop.Notifications serial=42 path=/org/freedesktop/Notifications; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method call time=1685385252.689504 sender=:1.354 -> destination=org.freedesktop.DBus serial=43 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.freedesktop.Notifications'"
method call time=1685385252.689563 sender=:1.354 -> destination=org.freedesktop.DBus serial=44 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.Notifications"
method call time=1685385252.690196 sender=:1.354 -> destination=org.freedesktop.Notifications serial=45 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "flameshot"
   uint32 0
   string "flameshot"
   string "Flameshot Info"
   string "Capture saved to clipboard."
   array [
   ]
   array [
   ]
   int32 5000
method call time=1685385252.699636 sender=:1.354 -> destination=org.freedesktop.DBus serial=46 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.Notifications'"

I have no idea if this is a flameshot specific error or if there is some kind of permission which flameshot lacks when called directly

Steps to reproduce

see above in the description

Screenshots or screen recordings

No response

System Information

System:
  Host: hogwart Kernel: 6.3.4-zen1-1-zen arch: x86_64 bits: 64 Desktop: GNOME
    v: 44.1 Distro: EndeavourOS
Graphics:
  Device-1: NVIDIA TU116M [GeForce GTX 1650 Ti Mobile] driver: nvidia
    v: 530.41.03
  Device-2: AMD Renoir driver: amdgpu v: kernel
  Device-3: Chicony HD Webcam driver: uvcvideo type: USB
  Display: wayland server: X.org v: 1.21.1.8 with: Xwayland v: 23.1.1
    compositor: gnome-shell v: 44.1 driver: X: loaded: amdgpu,nvidia
    unloaded: modesetting,radeon dri: radeonsi gpu: nvidia,amdgpu
    resolution: 1920x1080
  API: OpenGL v: 4.6 Mesa 23.1.1 renderer: AMD Radeon Graphics (renoir LLVM
    15.0.7 DRM 3.52 6.3.4-zen1-1-zen)
@manfredlotz manfredlotz added the Unconfirmed Bug The bug is not confirmed by anyone else. label May 29, 2023
@manfredlotz
Copy link
Author

I forgot to mention that in case the screenshot doesn't work I also see

May 29 13:01:49 hogwart xdg-desktop-por[8123]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 
Only the focused app is allowed to show a system access dialog

in the syslogs

@mmahmoudian
Copy link
Member

Thanks for the detailed report. It is highly appreciated.

@mmahmoudian mmahmoudian added High Priority Wayland Wayland specific issues labels May 30, 2023
@manfredlotz
Copy link
Author

I have to say thank you for your work on this great tool!! :-)

@jack9603301
Copy link
Contributor

@manfredlotz Hi, can you help to test if grim can take screenshots?

@manfredlotz
Copy link
Author

Hm, when I install grim from extra, i.e extra/grim 1.4.0-3 and try to start it I get

compositor doesn't support wlr-screencopy-unstable-v1

There is more grim like stuff in AUR. Which one should I try?

@jack9603301
Copy link
Contributor

Sure enough, wlroots' screenshot adapter doesn't work, can you find other command line screenshots for gnome?

@manfredlotz
Copy link
Author

You mean one working with Wayland, I assume. I will take a look.

@manfredlotz
Copy link
Author

The Gnome builtin screenshot utiliy works of course but I guess this is not a test you like to see.

@jack9603301
Copy link
Contributor

jack9603301 commented Jun 1, 2023

You mean one working with Wayland, I assume. I will take a look.

yep

Just find the command line screencast tool for gnome's wayland technology, and I'll be able to use it as a screencast adapter

@jack9603301
Copy link
Contributor

The Gnome builtin screenshot utiliy works of course but I guess this is not a test you like to see.

It should be a command-line screenshot tool that can output screenshots through stdout or files, without any graphical interface, and it applies to the wayland screenshot protocol of GNOME and can work properly in the wayland environment of gnome.

@jack9603301
Copy link
Contributor

@manfredlotz Can you help me find it?

@manfredlotz
Copy link
Author

I will try. I wasn't yet successful to find a command line screenshot tool working with Wayland. Searching....

@jack9603301
Copy link
Contributor

I will try. I wasn't yet successful to find a command line screenshot tool working with Wayland. Searching....

If you find it, just let me know, and then I'll check the documentation for this tool, and then, I'll submit a PR to enable this adapter.

This solves the problem of relying on dbus under wayland

@manfredlotz
Copy link
Author

manfredlotz commented Jun 1, 2023

Not yet found anything. The only quick and dirty way I found was

This works fine.

Should add that I did not specifically set any env var.

@jack9603301
Copy link
Contributor

Using dbus to take screenshots in wayland is not a good idea. I prefer to use a screenshot adapter that supports the corresponding wayland compositor screenshot protocol

I'll look for it, but I'm not sure I can find the right one. If you can, please let me know.

@manfredlotz
Copy link
Author

It is not easy to find anything. I let you know if I will find something.

@jack9603301
Copy link
Contributor

jack9603301 commented Jun 2, 2023

@manfredlotz https://github.com/ksnip/ksnip

Can you help test this? Use the following command

ksnip -p 1.png -c

It also has a GUI function for editing, but we only need the command line

You can do automatic downloads from your distribution's package manager

@manfredlotz
Copy link
Author

Hm, when I try

ksnip -p 1.png -c I get

Info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Warning: No capture mode selected, using default.
Critical: Invalid reply from DBus: Screenshot is not allowed

Now trying: env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland ksnip -p 1.png -c

and get

Critical: Unknown platform, using default X11 Image Grabber.
Warning: No capture mode selected, using default.
fish: Job 1, 'env XDG_SESSION_TYPE= QT_QPA_PL…' terminated by signal SIGSEGV (Address boundary error)

@jack9603301
Copy link
Contributor

Hm, when I try

ksnip -p 1.png -c I get

Info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Warning: No capture mode selected, using default.
Critical: Invalid reply from DBus: Screenshot is not allowed

Now trying: env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland ksnip -p 1.png -c

and get

Critical: Unknown platform, using default X11 Image Grabber.
Warning: No capture mode selected, using default.
fish: Job 1, 'env XDG_SESSION_TYPE= QT_QPA_PL…' terminated by signal SIGSEGV (Address boundary error)

GNOME seems to have only a dbus screenshot interface, my goodness!

@jack9603301
Copy link
Contributor

env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland ksnip -p 1.png -c

env XDG_SESSION_TYPE=gnome QT_QPA_PLATFORM=wayland ksnip -p 1.png -c

try

@manfredlotz
Copy link
Author

OK, I tried env XDG_SESSION_TYPE=gnome QT_QPA_PLATFORM=wayland ksnip -p 1.png -c

and got

Critical: Unknown platform, using default X11 Image Grabber.
Warning: No capture mode selected, using default.
fish: Job 1, 'env XDG_SESSION_TYPE=gnome QT_Q…' terminated by signal SIGSEGV (Address boundary error)

When I do env XDG_SESSION_TYPE=wayland QT_QPA_PLATFORM=wayland ksnip -p 1.png -c I can select an area for the screenshot but I get the following and there is no file 1.png

Info: Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Warning: No capture mode selected, using default.
Warning: Wayland does not support QWindow::requestActivate()
Critical: Invalid reply from DBus: Screenshot is not allowed

@jack9603301
Copy link
Contributor

@manfredlotz okay It looks like gnome has to interface via the dbus bus

@jack9603301
Copy link
Contributor

@manfredlotz Can you check if gnome's official screenshot tool can meet the following requirements:

  1. pure command line calls
  2. can be invoked without GUI interface
  3. full-screen screenshots can be saved directly to a specified file or output from a standard output stream

If these requirements can be met, please provide valid command line parameters and explanation of the parameters

@manfredlotz
Copy link
Author

In Gome 44 the screenshot utility is just part of gnome-shell

But I could install gnome-screenshot 41.0+r25+g45f08f0-1 and running gnome-screenshot -f 1.png in a terminal did just work fine.

-f, --file=filename            Save screenshot directly to this file

@jack9603301
Copy link
Contributor

@manfredlotz okay,I got it

@jack9603301
Copy link
Contributor

@manfredlotz #3215

Please help test this commit with the following cmake parameters

-DUSE_WAYLAND_GNOME=true

@jack9603301
Copy link
Contributor

Well, then it seems to be an oops, I had thought that dbus direct communication didn't seem to work in your environment

@mmahmoudian Now, a community decision is needed on whether the gnome adapter should be added

@mmahmoudian
Copy link
Member

@jack9603301 we are short in developers, and getting new developers and contributors is the main priority at the moment. There are lots of PRs that should be reviewed and merged and some high priority bugs

@jack9603301
Copy link
Contributor

@mmahmoudian Yes, I agree, it takes a sustained community effort, the perfect open source product is not done by one person, it has to be driven by the community - the big difference with the commercial product model is that commercial products are company driven, the company can hire people or hire regular members by paying them a salary to do it But the main members of the open source community are just enthusiasts - even if it temporarily finds other people or freelancers, the main developers driving the project are still just enthusiasts, relying on their personal commitment to do it for free, so we just need to do it ourselves

The community philosophy of the open source community is - no one is obligated to make guarantees for anyone indefinitely, unless you pay someone to do it for you full time or on a temporary basis as a freelancer, otherwise, if you want a feature and it's not there, either wait or implement it yourself!

@jack9603301
Copy link
Contributor

@mmahmoudian Maybe flameshot needs full documentation, including how to contribute, and maybe it can attract new users to come forward to contribute

@mmahmoudian
Copy link
Member

mmahmoudian commented Jun 3, 2023

@jack9603301 please you and anyone else who is willing to discuss this matter join the Matrix room "Developers" from the following Matrix Space so we can discuss the plausible ways to attract new contributors:

https://matrix.to/#/#flameshot-org:matrix.org

That channel is open 24/7 and we can give it few days to hear all opinions

I will hide these last few comments as off-topic at some point, but for the next few days they will be visible to inform all.

Thanks

@manfredlotz
Copy link
Author

manfredlotz commented Jun 3, 2023

The security window only popping up when flameshot configuration window is open, is this a bug in flameshot or is it a bug in dbus?

@jack9603301
Copy link
Contributor

jack9603301 commented Jun 3, 2023

The security window only popping up when flameshot configuration window is open, is this a bug in flameshot or is it a bug in dbus?

It's weird, I thought at first that I couldn't take screenshots via command line and gui any way so I added an adapter, yet now you're telling me the original mainline branch screenshot program is accessible too! So what was this problem to begin with?

@manfredlotz
Copy link
Author

manfredlotz commented Jun 3, 2023

Now in the end we recognized that the original problem was that

  • when trying a screenshot by clicking on the flameshot tray icon
  • the security window to ask if I want to allow flameshot taking screenshots didn't appear
  • and the same time there was a message in the syslog
xdg-desktop-por[6966]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog

Only when I opened flameshot configuration dialog first and then tried to get a screenshot by clicking on the flameshot tray icon the security window asking me if I want to allow taking screenshots popped up.

Now all is working fine.

As asked above: a bug in flameshot, a bug in dbus or (just came to my mind), a bug in Gnome somewhere?

@jack9603301
Copy link
Contributor

@manfredlotz I think it's the gnome security restrictions! If you feel this restriction is holding you back, I think you might consider other wayland implementations like hyprland!

@manfredlotz
Copy link
Author

I have no problem that Gnome asks me to allow flameshot to take screenshots as this is asked only one time.

My problem is that without the flameshot configuration window open I dont' see the security window and such don't know that Gnome wants to ask me.

@jack9603301
Copy link
Contributor

I have no problem that Gnome asks me to allow flameshot to take screenshots as this is asked only one time.

My problem is that without the flameshot configuration window open I dont' see the security window and such don't know that Gnome wants to ask me.

I think this might be a bug in gnome

It is not flameshot's problem

@mmahmoudian
Copy link
Member

@manfredlotz As @jack9603301 kindly pointed out, that sounds like yet another Gnome issue.

@manfredlotz
Copy link
Author

Yes, it could well be that this is some Gnome issue.

@jack9603301
Copy link
Contributor

Yes, it could well be that this is some Gnome issue.

If you wish, you should file a bug report with the GNOME project

@jack9603301
Copy link
Contributor

@mmahmoudian Now there is one more question

About #3215

Does it still need to be merged? It uses the gnome command line adapter

@keteague
Copy link

keteague commented Jun 26, 2023

@manfredlotz Thanks for the troubleshooting.

@jack9603301 I've also had this problem for quite some time. Thank you for finding an alternate method to get this to work.

I've read through this thread implemented the same stuff that you had @manfredlotz do, with the exception of -DCMAKE_INSTALL_PREFIX=/home/ken.

When I attempt to take a screenshot after invoking ./flameshot from $HOME/ken/bin, I receive an error Unable to capture screen. Since flameshot is run from the command line and not forked to the background, I see this error:

QFile::remove: Empty or null file name
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout

In another terminal window, I'm monitoring dbus a la dbus-monitor --session sender=org.flameshot.Flameshot. Before launching flameshot, I see:

signal time=1687811853.250121 sender=org.freedesktop.DBus -> destination=:1.501 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
   string ":1.501"
signal time=1687811853.250150 sender=org.freedesktop.DBus -> destination=:1.501 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
   string ":1.501"

Upon initial launching of flameshot, I see:

method call time=1687812038.155358 sender=:1.509 -> destination=org.freedesktop.DBus serial=12 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=1687812038.155379 sender=:1.509 -> destination=org.freedesktop.DBus serial=13 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameHasOwner
   string "org.a11y.Bus"
method call time=1687812038.155432 sender=:1.509 -> destination=org.freedesktop.DBus serial=14 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=1687812038.155463 sender=:1.509 -> destination=org.freedesktop.DBus serial=15 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.a11y.Bus"
method call time=1687812038.155526 sender=:1.509 -> destination=org.a11y.Bus serial=16 path=/org/a11y/bus; interface=org.freedesktop.DBus.Properties; member=Get
   string "org.a11y.Status"
   string "ScreenReaderEnabled"
method call time=1687812038.155711 sender=:1.509 -> destination=org.a11y.Bus serial=17 path=/org/a11y/bus; interface=org.freedesktop.DBus.Properties; member=Get
   string "org.a11y.Status"
   string "IsEnabled"

When I take a screenshot, I hear two camera snapshot sounds and see this:

method call time=1687812065.112624 sender=:1.509 -> destination=org.freedesktop.portal.Desktop serial=18 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method call time=1687812065.113992 sender=:1.509 -> destination=org.freedesktop.DBus serial=19 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.freedesktop.portal.Desktop'"
method call time=1687812065.114011 sender=:1.509 -> destination=org.freedesktop.DBus serial=20 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1687812065.114112 sender=:1.509 -> destination=org.freedesktop.DBus serial=21 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1687812065.114186 sender=:1.509 -> destination=org.freedesktop.DBus serial=22 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',path='/org/freedesktop/portal/desktop/request/1_509/2def2bdd423e495b9e1d9f168197ab05',interface='org.freedesktop.portal.Request',member='Response'"
method call time=1687812065.114194 sender=:1.509 -> destination=org.freedesktop.DBus serial=23 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.freedesktop.portal.Desktop'"
method call time=1687812065.114216 sender=:1.509 -> destination=org.freedesktop.DBus serial=24 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method call time=1687812065.114296 sender=:1.509 -> destination=org.freedesktop.portal.Desktop serial=25 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "2def2bdd423e495b9e1d9f168197ab05"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]
method call time=1687812065.672334 sender=:1.509 -> destination=org.freedesktop.portal.Desktop serial=26 path=/org/freedesktop/portal/desktop/request/1_509/2def2bdd423e495b9e1d9f168197ab05; interface=org.freedesktop.portal.Request; member=Close
method call time=1687812065.672471 sender=:1.509 -> destination=org.freedesktop.Notifications serial=27 path=/org/freedesktop/Notifications; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method call time=1687812065.672968 sender=:1.509 -> destination=org.freedesktop.DBus serial=28 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.freedesktop.Notifications'"
method call time=1687812065.672998 sender=:1.509 -> destination=org.freedesktop.DBus serial=29 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.Notifications"
method call time=1687812065.673150 sender=:1.509 -> destination=org.freedesktop.Notifications serial=30 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "flameshot"
   uint32 0
   string "flameshot"
   string "Flameshot Error"
   string "Unable to capture screen"
   array [
   ]
   array [
   ]
   int32 5000
method call time=1687812065.681834 sender=:1.509 -> destination=org.freedesktop.DBus serial=31 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.Notifications'"
method call time=1687812065.681972 sender=:1.509 -> destination=org.freedesktop.DBus serial=32 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',path='/org/freedesktop/portal/desktop/request/1_509/2def2bdd423e495b9e1d9f168197ab05',interface='org.freedesktop.portal.Request',member='Response'"
method call time=1687812065.681987 sender=:1.509 -> destination=org.freedesktop.DBus serial=33 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.portal.Desktop'"
method call time=1687812065.682016 sender=:1.509 -> destination=org.freedesktop.DBus serial=34 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.portal.Desktop'"
method call time=1687812065.682044 sender=:1.509 -> destination=org.freedesktop.DBus serial=35 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.freedesktop.Notifications'"
method call time=1687812065.682075 sender=:1.509 -> destination=org.freedesktop.DBus serial=36 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.Notifications"
method call time=1687812065.682244 sender=:1.509 -> destination=org.freedesktop.Notifications serial=37 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "flameshot"
   uint32 0
   string "flameshot"
   string "Flameshot Error"
   string "Unable to capture screen"
   array [
   ]
   array [
   ]
   int32 5000
method call time=1687812065.685904 sender=:1.509 -> destination=org.freedesktop.DBus serial=38 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RemoveMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',arg0='org.freedesktop.Notifications'"

And journalctl -n 100 -f reveals:

Jun 26 15:46:04 rokete xdg-desktop-por[73211]: Unhandled parent window type 
Jun 26 15:46:04 rokete xdg-desktop-por[73211]: Failed to associate portal window with parent window ''
Jun 26 15:46:04 rokete rclone[3665]: ERROR : Screenshot-25.png: WriteFileHandle.New Rcat failed: failed to create temporary local FS to spool file: stat /tmp/rclone/ken/pictures: no such file or directory
Jun 26 15:46:04 rokete rclone[3665]: ERROR : Screenshot-25.png: WriteFileHandle.Write error: io: read/write on closed pipe
Jun 26 15:46:04 rokete rclone[3665]: ERROR : IO error: io: read/write on closed pipe
Jun 26 15:46:04 rokete rclone[3665]: ERROR : Screenshot-25.png: WriteFileHandle.Write error: io: read/write on closed pipe
Jun 26 15:46:04 rokete rclone[3665]: ERROR : IO error: io: read/write on closed pipe
Jun 26 15:46:04 rokete rclone[3665]: ERROR : Screenshot-25.png: WriteFileHandle.Flush error: failed to create temporary local FS to spool file: stat /tmp/rclone/ken/pictures: no such file or directory
Jun 26 15:46:04 rokete rclone[3665]: ERROR : IO error: failed to create temporary local FS to spool file: stat /tmp/rclone/ken/pictures: no such file or directory
Jun 26 15:46:04 rokete dbus-daemon[3657]: [session uid=1000 pid=3657] Activating via systemd: service name='org.freedesktop.Tracker3.Miner.Extract' unit='tracker-extract-3.service' requested by ':1.81' (uid=1000 pid=4600 comm="/usr/libexec/tracker-miner-fs-3")
Jun 26 15:46:04 rokete systemd[3602]: Starting tracker-extract-3.service - Tracker metadata extractor...
Jun 26 15:46:04 rokete dbus-daemon[3657]: [session uid=1000 pid=3657] Successfully activated service 'org.freedesktop.Tracker3.Miner.Extract'
Jun 26 15:46:04 rokete systemd[3602]: Started tracker-extract-3.service - Tracker metadata extractor.
Jun 26 15:46:04 rokete rclone[3665]: ERROR : IO error: can't open file - writer failed
Jun 26 15:46:04 rokete tracker-extract[77468]: Task for 'file:///home/ken/Pictures/Screenshot-25.png' finished with error: Could not get any metadata for uri:'file:///home/ken/Pictures/Screenshot-25.png' and mime:'image/png'

Note that $HOME/Pictures is mounted to my OneDrive account using rclone even though my flameshot.ini is configured to save my screenshots to /home/ken/tmp.

ken@rokete:~/.config/flameshot$ cat flameshot.ini 
[General]
contrastOpacity=188
drawThickness=1
filenamePattern=Screenshot_%F_%H%M%S
savePath=/home/ken/tmp
uiColor=#e71010

I've got so far as to remove the flameshot package that's included in the Debian repo to make sure it's not being used in any way.

OS: Debian (testing)

@Mikenux
Copy link

Mikenux commented Aug 25, 2023

Hello! Maybe this: flatpak/xdg-desktop-portal#1070 (comment)?

Comment edited to show correct link.

@swick
Copy link

swick commented Aug 25, 2023

in commit 8ff94a9 the desktop and icon files were renamed. This is a mistake. The names should match the executable instead, like it did before (for flatpak, the manifest has support for file-renaming https://docs.flatpak.org/en/latest/manifests.html#file-renaming so this is not an issue).

The desktop file needs to match the executable when launched as a command for the portal to pick up the desktop file for it.

The remaining issue is that the security policy of mutter doesn't allow an app without a focused window to show a permission dialog (which makes sense, because you can't tell which app is requesting permission without a visible window). There is really something that flameshot has to fix somehow.

@swick
Copy link

swick commented Aug 25, 2023

One more thought: it would be possible to try to take a screenshot without starting the UI, if that fails, start the UI, take a screenshot again.

The first time the user tries to take a screenshot, it will fail, the UI will start, the user can then select to always allow the app to take screenshots. When the user then tries to take a screenshot again, it will work without the UI starting.

@paul9115
Copy link

paul9115 commented Sep 14, 2023

Not sure how much I can contribute to this since the original report was so detailed, but I can confirm I'm facing the same issues on Arch (Gnome 44.4) and Flameshot v12.1.0 (a7e0a61) Compiled with Qt 5.15.10

I also tried to create a script to launch the application which does work

#! /bin/sh

env XDG_SESSION_TYPE= QT_QPA_PLATFORM=wayland /usr/bin/flameshot

and linking the Exec entry in the .desktop file to the script instead of the binary, but this still seems to launch the application without the environment variables.

@fabifont
Copy link

fabifont commented May 5, 2024

Now in the end we recognized that the original problem was that

* when trying a screenshot by clicking on the flameshot tray icon

* the security window to ask if I want to allow flameshot taking screenshots didn't appear

* and the same time there was a message in the syslog
xdg-desktop-por[6966]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog

Only when I opened flameshot configuration dialog first and then tried to get a screenshot by clicking on the flameshot tray icon the security window asking me if I want to allow taking screenshots popped up.

Now all is working fine.

As asked above: a bug in flameshot, a bug in dbus or (just came to my mind), a bug in Gnome somewhere?

Hi, I have the same problem, but the permission popup won't come up even if I open the configuration dialog before taking the screenshot. Do you know of any way to fix this?

@keteague
Copy link

keteague commented May 5, 2024 via email

@fabifont
Copy link

fabifont commented May 5, 2024

I couldn't find a solution so I had to stop using flameshot

On Sun, May 5, 2024, 12:52 PM Fabio Fontana @.> wrote: Now in the end we recognized that the original problem was that * when trying a screenshot by clicking on the flameshot tray icon * the security window to ask if I want to allow flameshot taking screenshots didn't appear * and the same time there was a message in the syslog xdg-desktop-por[6966]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog Only when I opened flameshot configuration dialog first and then tried to get a screenshot by clicking on the flameshot tray icon the security window asking me if I want to allow taking screenshots popped up. Now all is working fine. As asked above: a bug in flameshot, a bug in dbus or (just came to my mind), a bug in Gnome somewhere? Hi, I have the same problem, but the permission popup won't come up even if I open the configuration dialog before taking the screenshot. Do you know of any way to fix this? — Reply to this email directly, view it on GitHub <#3213 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFRPVMLDV5IUVTLIHNU4EF3ZAZWVZAVCNFSM6AAAAAAYTC34B2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJUHA4TENZRG4 . You are receiving this because you commented.Message ID: @.>

I found a workaround. I downgraded xdg-desktop-portal to version 1.16.0 and xdg-desktop-portal-gnome to version 43.1, then I started flameshot, opened the settings panel from the tray icon and then I tried to capture a screenshot. Finally the permission popup appeared, I accepted it and now I am able to take screenshots with the classical shortcut I was using. I also re-upgraded the packages and it is still working.

@aleb
Copy link

aleb commented May 14, 2024

It works with a workaround:

  1. notice when you run flameshot config it prints Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
  2. run QT_QPA_PLATFORM=wayland flameshot config to open the flameshot config window
  3. press Win key to display the open apps at the bottom of the screen
  4. right-click the flameshot icon and choose "Take screenshot" in the menu
  5. notice the system dialog asking for permission, allow it
  6. create a wrapper script and create a custom system keyboard shortcut so that the PrintScreen keyboard activates it:
$ nano ~/bin/flameshot-wrapper
#!/bin/sh
QT_QPA_PLATFORM=wayland flameshot gui
$ chmod u+x ~/bin/flameshot-wrapper

Maybe it works without the wrapper if you put QT_QPA_PLATFORM=wayland in your ~/.profile.. not sure what it could break.

$ pacman -Ss xdg-desktop | grep installed
extra/xdg-desktop-portal 1.18.4-1 [installed]
extra/xdg-desktop-portal-gnome 46.1-1 (gnome) [installed]
extra/xdg-desktop-portal-gtk 1.15.1-2 [installed]

@m44soroush
Copy link

Thanks @aleb for the solution. I have Ubuntu 24.04 with the same problem, and setting that env solved my problem.

Also if Falmeshot is installed via apt, you can change the desktop entry like this:
/usr/share/applications/org.flameshot.Flameshot.desktop

Exec=env T_QPA_PLATFORM=wayland flameshot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority Unconfirmed Bug The bug is not confirmed by anyone else. Wayland Wayland specific issues
Projects
None yet
Development

No branches or pull requests

10 participants