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`:
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.
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.
Yeah, that’s my point, it’s clearly not inherited by subprocesses
That said, in nushell technically echo $env.QT_QPA_PLATFORMis 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…
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.
~
❯
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.
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?
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.
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):
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.
~ 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)
❯
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.