Flameshot aborts on Wayland/GNOME

I’m having a really strange problem while using flameshot.

When I try running flameshot gui inside terminal I get:

✦ ❯ flameshot gui
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Screenshot aborted.

So I tried setting QT_QPA_PLATFORM to wayland:

✦ ❯ set QT_QPA_PLATFORM wayland

✦ ❯ echo $QT_QPA_PLATFORM
wayland

✦ ❯ flameshot gui
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Screenshot aborted.

I can’t find anything related to my issue on discourse nor github issues.

I have installed flameshot from nixpks like this in `configuration.nix`:

    (flameshot.override {enableWlrSupport = true;})

Has anyone faced this and/or solved this problem?

1 Like

If you’re using bash - the keyword is export (not set), if you want to change an envvar.

export QT_QPA_PLATFORM=wayland

That’s strange, I’m also using flameshot on GNOME 49, and see no such warnings when invoking flameshot gui via terminal; screenshotting works as intended. Also, Wayland support is enabled by default, unless you’re using Nix on Darwin. Could you tell more about your system? That might come in handy.

As an aside using flameshot on GNOME is often a mess due to GNOME itself (just look at all the issues about not being able to take screenshots via shortcuts). But let’s try to figure what’s up.

@waffle8946 the env var does look to be “set”:

But indeed, this sounds more like a shell issue than something with flameshot. It clearly can’t see the variable, so that means the shell isn’t making subprocesses inherit that variable. Maybe export is indeed the right keyword, but this is definitely not bash.

That’ll be for wlroots compositors, like sway or niri. GNOME is GNOME (well, the compositor is technically known as mutter), not a wlroots compositor.

That’s not how you check envvars in any shell language, because echo $var is going to include locally scoped shell vars.

In bash/zsh the correct 2nd command is printenv QT_QPA_PLATFORM; if this is fish, then the correct setting and printing commands are (as mentioned in set - display and change shell variables — fish-shell 4.2.1 documentation):

set -gx QT_QPA_PLATFORM wayland

set -S QT_QPA_PLATFORM
2 Likes

Yeah, that’s my point, it’s clearly not inherited by subprocesses :wink:

That said, in nushell technically echo $env.QT_QPA_PLATFORM is a correct way to check, for example. Traditional shells do indeed have a much less obvious distinction between locally scoped and inherited variables, one of their many footguns…

Yes, sure.

OS: NixOS 25.11.20251223.76701a1
Shell: fish
DE: GNOME 49.2 (Wayland)
WM: Mutter

Let me know if anything is missing.

Sorry for lack of information, I forgot to mention I was using fish. I didn’t know about printenv

❯ printenv QT_QPA_PLATFORM
wayland

I have tried setting with -gx flag too. But it didn’t help:

❯ printenv QT_QPA_PLATFORM
wayland
~
❯ set -gx QT_QPA_PLATFORM wayland
~
❯ flameshot gui
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Screenshot aborted.
~
❯

Should I remove this? I copied it from documentation from here:

To install flameshot on Wayland, add the following to your package list:

(flameshot.override { enableWlrSupport = true; })

The wiki isn’t documentation, but random people writing stuff, and unfortunately we don’t have the editorial capacity to make sure any of it is sensible. Whoever wrote that probably doesn’t understand the difference between wlroots and wayland or didn’t care to be precise for use cases other than their own.

All that setting does is add grimshot to the binary’s $PATH and force you to rebuild it locally; this is completely pointless on GNOME and wastes time and electricity.

1 Like

I see, I removed enableWlrSupport in my home.nix, but it still doesn’t seem to work.

✦ ❯ flameshot guiWarning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use 
QT_QPA_PLATFORM=wayland to run on Wayland anyway.flameshot: error: Unable to
capture screenflameshot: error: Unable to capture screenQLayout: Attempting to add 
QLayout “” to SidePanelWidget “”, which already has a layout
flameshot: info: 
Screenshot aborted.

✦ ❯ printenv QT_QPA_PLATFORM
wayland

Yes, that’s unrelated. I don’t know why the flameshot process doesn’t pick up that variable. Is there perhaps a long-running instance in the background that was started before the variable was set (or in a different context entirely) which is being communicated with via IPC?

Thanks for the idea.

✦ ❯ pidof flameshot

didn’t return any value, it had non-zero exit code too. For the assurance I tried killing it too.

✦ ❯ kill flameshot
kill: cannot find process “flameshot”

✦ ❯ printenv QT_QPA_PLATFORM
wayland

✦ ❯ flameshot gui
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Screenshot aborted.

Due to wrapping, quite often foo doesn’t exist in the process tree but .foo-wrapped instead.

Using htop and filtering or ps -aux or whatever with grep usually works better.

UPD.

So I think indeed there was a long-running process. I rebuild the service to rerun flameshot, It didn’t have a tray icon, so I have installed an extension, so I can see a flameshot running.

I clicked on the icon, and then “Take a screenshot“, it triggered the gui. It worked perfectly I have selected some area, but I can’t save it nor copy it. It coredumped. In any case, logs are here(from Logs app on GNOME):

image

Hey, sorry, just got time to look here. I see you made progress though, that’s great!
So this schema issue is something I opened a PR for, because someone else also reported a similar issue earlier.

In the meantime, you could override the package’s attributes to add wrapGAppsHook3, which will resolve this error. To first test it, try: nix-shell -p 'flameshot.overrideAttrs (old: {nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ wrapGAppsHook3 ];})'


Note: This problem appears in a suite of Qt apps, and for now it’s addressed at a package level as they appear.

2 Likes

Thank you for spending your time. However I couldn’t make any progress, I have tried the command you have provided:

✦ ❯ nix-shell -p 'flameshot.overrideAttrs (old: {nativeBuildInputs = (old.nativeBuildInputs or []) ++ [ wrapGAppsHook3 ];})' 

❯ flameshot 
flameshot: error: Unable to capture screen 
flameshot: error: Unable to capture screen 
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout

And is it the same with flameshot gui?

Yes:

~ via ❄️  impure (shell)
❯ flameshot gui
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
flameshot: info: Screenshot aborted.
QThreadStorage: entry 2 destroyed before end of thread 0x55e622ea6150
QThreadStorage: entry 1 destroyed before end of thread 0x55e622ea6150
~ via ❄️  impure (shell)
❯

Hmm, interesting… I want to say it could be a screenshotting permission issue on GNOME, which can be reset with the command below.

dbus-send --session  --print-reply=literal --dest=org.freedesktop.impl.portal.PermissionStore /org/freedesktop/impl/portal/PermissionStore org.freedesktop.impl.portal.PermissionStore.DeletePermission string:'screenshot' string:'screenshot' string:''

But since the GUI appeared before just fine (minus saving the clipboard), I doubt this would help. I would expect issues when running flameshot and trying to take a screenshot from a shortcut or the tray icon, but not from the terminal. :confused: