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

Take Screenshot on Gnome without Prompt #2868

Open
borgmanJeremy opened this issue Aug 11, 2022 · 31 comments
Open

Take Screenshot on Gnome without Prompt #2868

borgmanJeremy opened this issue Aug 11, 2022 · 31 comments
Assignees
Labels
Enhancement Feature requests and code enhancements Linux Linux specific issue Wayland Wayland specific issues

Comments

@borgmanJeremy
Copy link
Contributor

Feature Description

This issue is to track updating Flameshot to use the new permission store that was merged into to xdg-desktop-portal: flatpak/xdg-desktop-portal#649 (comment)

This will allow users to take a screenshot without hitting the share button each time.

@borgmanJeremy borgmanJeremy added the Enhancement Feature requests and code enhancements label Aug 11, 2022
@mmahmoudian mmahmoudian added the Linux Linux specific issue label Aug 11, 2022
@GeorgesStavracas
Copy link

That portal change has been merged, and is part of the 1.15.0 release, and GNOME 43 will support that. The KDE portal implementation already skips the sharing dialog anyway, so it's not relevant. Requesting the screenshot permission happens the first time when using the GUI, and after that permission is granted, subsequent non-interactive screenshots should happen automatically. Taking screenshots from the CLI won't work without the permission.

@GeorgesStavracas
Copy link

I sent the comment too early, sorry. Some more thoughts.

Taking screenshots from the CLI won't work without the permission.

GNOME rejects permission requests from apps that are not the currently focused window, but xdg-desktop-portal only requests such permission if it's unset. If the user grants (or denies) the permission, it'll be stored and xdg-desktop-portal won't request it again. So if someone tries to take a screenshot using CLI, and it's the first time using the app, the permission request will fail. But in GNOME, people can go to Settings and manually grant Flameshot this permission using the Applications panel:

image

I'm still considering whether or not this case should be covered, and how to do so, but keep this in mind for now.

@GeorgesStavracas
Copy link

To be abundantly clear, Flameshot won't have to do anything other than using the Screenshot portal, and pass interactive=false. Everything else will be handled internally by xdg-desktop-portal and GNOME.

@borgmanJeremy
Copy link
Contributor Author

Thanks for the additional info! I’ll try to get the change merged into Flameshot this weekend.

@mmahmoudian
Copy link
Member

@GeorgesStavracas thanks for the detailed explanation, and thanks for the PR you did for the xdg-desktop-portal. I will try to update our documentation on our website. Do you kind if I ask you later to review the updates in case I've missed or misunderstood something?

@GeorgesStavracas
Copy link

Sure, just @ me and I can give it a read

@uacode
Copy link

uacode commented Sep 28, 2022

How I can resubmit request for the permission?

Flameshot v12.1.0 (-)
https://ibb.co/1dTFj0t
https://ibb.co/VNc5RJ9

@jerzy-dudzic
Copy link

Hi guys,
I was going to add my 2 cents on how it doesn't work for me, but then I experimented a bit more and it started working.

OS: Fedora 37, Wayland, Gnome 43, Flameshot: 12.1.0 installed using dnf, xdg-desktop-portal-1.15.0-1.fc37

What I did to make it work:

  1. Run flameshot
  2. Open flameshot's settings window(I also maximized the window to lower the chances of loosing focus of that window - probably not needed)
  3. Take a screenshot using flameshot - I clicked the tray icon that came from a gnome extension
  4. Permissions question should appear - grant it
  5. It should now work fine without asking for permissions next time you take a screenshot

The same can be done for flameshot run from the terminal, or triggered by a keyboard shortcut. You need to run flameshot in the terminal instead of using gnome launcher, and repeat the above steps. In this case I don't know if it's the flameshot settings window that needs to be actively focused to trigger the permissions prompt. But it's one of those.

In summary, I can now run flameshot from the tray icon, from terminal, from the ALT+F2(gnome's run command tool) and it takes screenshots without asking for permissions.

@f1lipe
Copy link

f1lipe commented Nov 13, 2022

Hi guys, I was going to add my 2 cents on how it doesn't work for me, but then I experimented a bit more and it started working.

OS: Fedora 37, Wayland, Gnome 43, Flameshot: 12.1.0 installed using dnf, xdg-desktop-portal-1.15.0-1.fc37

What I did to make it work:

1. Run flameshot

2. Open flameshot's settings window(I also maximized the window to lower the chances of loosing focus of that window - probably not needed)

3. Take a screenshot using flameshot - I clicked the tray icon that came from a gnome extension

4. Permissions question should appear - grant it

5. It should now work fine without asking for permissions next time you take a screenshot

The same can be done for flameshot run from the terminal, or triggered by a keyboard shortcut. You need to run flameshot in the terminal instead of using gnome launcher, and repeat the above steps. In this case I don't know if it's the flameshot settings window that needs to be actively focused to trigger the permissions prompt. But it's one of those.

In summary, I can now run flameshot from the tray icon, from terminal, from the ALT+F2(gnome's run command tool) and it takes screenshots without asking for permissions.

Hi @jerzy-dudzic. Thanks for your 2 cents. I'm running the same version as you and I was able to grant permission running flameshot from its .desktop gnome menu. But when I try to run it from terminal it doesn't work (never asks for permission). Besides just 'flameshot' I also try running the same .desktop file (gtk4-launch org.flameshot.Flameshot.desktop) but same result:
flameshot: error: Unable to capture screen

Could you provide more details on how you achieved to run flameshot from terminal? Or do you have any idea about what I am missing here.

Thanks.

@uacode
Copy link

uacode commented Nov 13, 2022

How to request permissions?

@jerzy-dudzic
Copy link

I just tested this on a second computer with Fedora 37. What worked for me is simply running flameshot command in the terminal(gnome-terminal as terminal, fish as shell). Terminal was the only window I had on the whole screen. Flameshot created a tray icon, I clicked on it and I chose to take a screenshot. Permissions prompt showed up. The tray extension I'm using is "AppIndicator and KStatusNotifierItem Support".

I believe that for this to work the terminal window must not lose focus. It's just a guess but I suspect you might be able to set the keyboard shortcut to flameshot screen for example, and then use that shortcut while having a terminal window with flameshot running and focused.

This theory is based on the quote of @GeorgesStavracas, although it's a bit counter-intuitive that it's the terminal window must be focused instead of flameshot. However maybe it's the terminal or even a shell that must be granted permissions for taking screenshots from the terminal. I don't know how to check those permissions. The quote is:

GNOME rejects permission requests from apps that are not the currently focused window

If anyone knows how to clear those permissions please let me know and I'll do some more tests.

@yajo
Copy link

yajo commented Nov 17, 2022

I'm using GNOME 43 in Fedora 37.

I had a keyboard shortcut that worked nicely in Fedora 36, launching the command flatpak run org.flameshot.Flameshot gui.

That one no longer works. Fails with:

> flatpak run org.flameshot.Flameshot gui
Gtk-Message: 11:23:54.229: Failed to load module "canberra-gtk-module"
Gtk-Message: 11:23:54.229: Failed to load module "canberra-gtk-module"
Qt: Session management error: None of the authentication protocols specified are supported

I had to change it for flatpak run org.flameshot.Flameshot launcher. Interestingly, it prints the same logs. But at least it works. It's not so much comfortable because it opens a launcher window where I have to take another shot to be able to edit it. But at least it works.

Is there any way to make flatpak run org.flameshot.Flameshot gui work again?

@Gustav0ar
Copy link

Gustav0ar commented Nov 26, 2022

I'm using GNOME 43 in Fedora 37.

I had a keyboard shortcut that worked nicely in Fedora 36, launching the command flatpak run org.flameshot.Flameshot gui.

That one no longer works. Fails with:

> flatpak run org.flameshot.Flameshot gui
Gtk-Message: 11:23:54.229: Failed to load module "canberra-gtk-module"
Gtk-Message: 11:23:54.229: Failed to load module "canberra-gtk-module"
Qt: Session management error: None of the authentication protocols specified are supported

I had to change it for flatpak run org.flameshot.Flameshot launcher. Interestingly, it prints the same logs. But at least it works. It's not so much comfortable because it opens a launcher window where I have to take another shot to be able to edit it. But at least it works.

Is there any way to make flatpak run org.flameshot.Flameshot gui work again?

Yes, please, I have the exact same issue with the keyboard shortcut, unable to run with flameshot gui and with the launcher option, I get notification with "Unable to capture screen" when clicking the button on the popup

❯ flameshot gui
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
flameshot: info: Screenshot aborted.

@Morikko
Copy link

Morikko commented Jan 16, 2023

I had the same issue. I probably said No once and it was saved when I was on Gnome 43. I found a solution to switch the permission.

Here the script to execute:

import dbus
bus = dbus.SessionBus()
perm = bus.get_object('org.freedesktop.impl.portal.PermissionStore', '/org/freedesktop/impl/portal/PermissionStore')
perm_iface = dbus.Interface(perm, dbus_interface='org.freedesktop.impl.portal.PermissionStore')

perm_iface.Lookup("screenshot", "screenshot")
perm_iface.Set("screenshot", dbus.Boolean(True), "screenshot", {"": ["yes"]}, dbus.Byte(0x00))
perm_iface.Lookup("screenshot", "screenshot")

I found the solution here: https://community.upwork.com/t5/Freelancers/Constantly-asking-for-permission-to-share-screenshot-on-Gnome/m-p/1222388#M731300

@acesabe
Copy link

acesabe commented Jan 16, 2023 via email

@ttys3
Copy link

ttys3 commented Feb 19, 2023

Hi guys, I was going to add my 2 cents on how it doesn't work for me, but then I experimented a bit more and it started working.

OS: Fedora 37, Wayland, Gnome 43, Flameshot: 12.1.0 installed using dnf, xdg-desktop-portal-1.15.0-1.fc37

What I did to make it work:

  1. Run flameshot
  2. Open flameshot's settings window(I also maximized the window to lower the chances of loosing focus of that window - probably not needed)
  3. Take a screenshot using flameshot - I clicked the tray icon that came from a gnome extension
  4. Permissions question should appear - grant it
  5. It should now work fine without asking for permissions next time you take a screenshot

The same can be done for flameshot run from the terminal, or triggered by a keyboard shortcut. You need to run flameshot in the terminal instead of using gnome launcher, and repeat the above steps. In this case I don't know if it's the flameshot settings window that needs to be actively focused to trigger the permissions prompt. But it's one of those.

In summary, I can now run flameshot from the tray icon, from terminal, from the ALT+F2(gnome's run command tool) and it takes screenshots without asking for permissions.

works! thank you

@uacode
Copy link

uacode commented Feb 23, 2023

How I fix it on fc38 Beta
https://i.imgur.com/do2GW65.png
In software I removed the package and then install it back, run the Flameshot - then App request permissions for making screenshots

All works perfect

@jack9603301
Copy link
Contributor

jack9603301 commented Jun 2, 2023

Hi, please see:

#3213

If the gnome test passes, maybe we can depend on it, or use the dbus path of this repo (for GNOME and KDE)

edit: Well, it looks like I can't use it - it doesn't solve the problem with the above issues of issues, still using dbus

@mmahmoudian
Copy link
Member

@GeorgesStavracas Is there any way to re-enable the "Share prompt" every time a screenshot is taken by third-party app? Besides downgrading to previous Gnome version?

This has nothing to do with Flameshot. It all depends on xdg portal of Gnome.

It was pointed out that you can use the Flatpak command to adjust this permission:

#3092 (comment)

I'm not a Gnome user so I leave it to your own judgement and experience.

@Tectract
Copy link

death by a thousand cuts. Debian linux doesn't know how to use the SCREENSHOT key without confirmation from the user.

@darkblaze69
Copy link

this looks irrelevant to modern days

@uacode
Copy link

uacode commented Dec 25, 2023

@darkblaze69 Disagree

Fedora 39, Wayland. Gnome 45.2
https://i.imgur.com/EHxQM2Q.png

@Tectract
Copy link

I'm using a modern stable version of Devuan with Mate desktop manager, and I had to write a script to call gnome-screenshot with special commands and specifying the screenshot / pictures folder for it, and call my script instead of gnome-screenshot, to suppress the user confimation window, so I think this is still a relevant issue. Windows 10/11 just knows, how to use the screenshot key on most keyboards.

@yajo
Copy link

yajo commented Dec 27, 2023

I use fedora 39 with gnome wayland and I can take screenshots without prompt with just a key combination. The issue is solved.

@lxwulf
Copy link

lxwulf commented Mar 7, 2024

How I fix it on fc38 Beta https://i.imgur.com/do2GW65.png In software I removed the package and then install it back, run the Flameshot - then App request permissions for making screenshots

All works perfect

So I had, as everyone in this thread, the same problem that I couldn't take screenshots anymore. At least not from the widget. From the terminal it worked without any issues via flameshot gui. So I read through this and other threads which are linked here.

So @uacode recommended based on his experience to reinstall flameshot. I did this but no change…
But this was not the end: I needed to select Take Screenshot in the widget menu. GNOME asked then for permission, which I allowed of course. Now it works from the terminal like before but also from the widget with double click.

What still does not work is via shortcut key. I set up my key PrtScn to execute flameshot gui but then the error remains Unable to capture screen. Strange right? Is this just a configuration error or do I need to give more permissions to flameshot, when yes how?

Under Apps in GNOME Settings I see no more options for flameshot than to give permission for sending notification or not.

Nonetheless, I hope what I found out so far could others which come across into this issue, also thank @uacode for the inspiration? 🤷‍♂️ and for giving direction.

TL;DR:

Fix taking screenshot with the widget

  1. remove flameshot
  2. install flameshot
  3. click on the widget and select Take Screenshot
  4. Allow the permission request
  5. You can take a screenshot with double-click on the flameshot widget

Information

System Details Report

  • OS Name: Fedora Linux 39 (Workstation Edition)
  • OS Build: (null)
  • OS Type: 64-bit
  • GNOME Version: 45.4
  • Windowing System: Wayland
  • Kernel Version: Linux 6.7.7-200.fc39.x86_64

Flameshot

  • Flameshot v12.1.0 (-)
  • Compiled with Qt 5.15.10

@uacode
Copy link

uacode commented Mar 7, 2024

I can use Flameshot only when I run it from Gnome Software (not from Apps or start on startup) :)

@lxwulf
Copy link

lxwulf commented Mar 13, 2024

How I fix it on fc38 Beta https://i.imgur.com/do2GW65.png In software I removed the package and then install it back, run the Flameshot - then App request permissions for making screenshots
All works perfect

So I had, as everyone in this thread, the same problem that I couldn't take screenshots anymore. At least not from the widget. From the terminal it worked without any issues via flameshot gui. So I read through this and other threads which are linked here.

So @uacode recommended based on his experience to reinstall flameshot. I did this but no change… But this was not the end: I needed to select Take Screenshot in the widget menu. GNOME asked then for permission, which I allowed of course. Now it works from the terminal like before but also from the widget with double click.

What still does not work is via shortcut key. I set up my key PrtScn to execute flameshot gui but then the error remains Unable to capture screen. Strange right? Is this just a configuration error or do I need to give more permissions to flameshot, when yes how?

Under Apps in GNOME Settings I see no more options for flameshot than to give permission for sending notification or not.

Nonetheless, I hope what I found out so far could others which come across into this issue, also thank @uacode for the inspiration? 🤷‍♂️ and for giving direction.

TL;DR:

Fix taking screenshot with the widget

  1. remove flameshot
  2. install flameshot
  3. click on the widget and select Take Screenshot
  4. Allow the permission request
  5. You can take a screenshot with double-click on the flameshot widget

Information

System Details Report

  • OS Name: Fedora Linux 39 (Workstation Edition)
  • OS Build: (null)
  • OS Type: 64-bit
  • GNOME Version: 45.4
  • Windowing System: Wayland
  • Kernel Version: Linux 6.7.7-200.fc39.x86_64

Flameshot

  • Flameshot v12.1.0 (-)
  • Compiled with Qt 5.15.10

Never mind I can't use it anymore…again the same issue which we have all here…

It does also not work with the flatpak version. There I can't even give screenshot permissions because there is no such entry...

@redsfyre
Copy link

redsfyre commented Apr 7, 2024

You may find this strange but i managed to take screenshot using shortcut. I use terminator as a terminal emulator and it has the ability to execute commands when opened. Simply create a custom shortcut with command: terminator -e "flameshot gui". Gnome-terminal also has the same feature, but it is included in the screenshot because it opens faster than terminator.
For people like me who have slowed down the graphics with blur and similar effects/themes, this might be useful.

https://imgur.com/a/IeY0SnW

edit: image added

@rgarrigue
Copy link

rgarrigue commented Apr 8, 2024

Thanks a lot for the idea @redsfyre. Running Manjaro / Gnome, couldn't find any combination that worked installing from whatever source with whatever ENV set (haven't searched for ages but still), but it works with this command

gnome-terminal -- /usr/bin/flameshot gui

Edit : I was actually annoyed by the gnome-terminal windows opening & being included in the screenshot itself. Tried to start it minimized or some sheganigan along those lines without success. And since I use Tilix most of the time anyway, , I switched to

tilix --minimize --command "/usr/bin/flameshot gui"

@Gustav0ar
Copy link

For me it works here with Flatpak and PrtScrn keyboard button in Gnome.

Command:
flatpak run org.flameshot.Flameshot gui

Shortcut:
Print

@lxwulf
Copy link

lxwulf commented Apr 16, 2024

For me it works here with Flatpak and PrtScrn keyboard button in Gnome.

Command: flatpak run org.flameshot.Flameshot gui

Shortcut: Print

I tried this, and it didn't work, sadly. I have the following log output in the terminal.

ok@thinkpadx395:~$ flatpak run org.flameshot.Flameshot gui
Gtk-Message: 17:55:38.035: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:55:38.035: Failed to load module "pk-gtk-module"
Gtk-Message: 17:55:38.036: Failed to load module "canberra-gtk-module"
Gtk-Message: 17:55:38.036: Failed to load module "pk-gtk-module"
qt.qpa.qgnomeplatform: Could not find color scheme  ""
Qt: Session management error: Could not open network socket
flameshot: error: Unable to capture screen
flameshot: error: Unable to capture screen
flameshot: info: Screenshot aborted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Feature requests and code enhancements Linux Linux specific issue Wayland Wayland specific issues
Projects
None yet
Development

No branches or pull requests