flameshot-org / flameshot

Powerful yet simple to use screenshot software :desktop_computer: :camera_flash:
https://flameshot.org
GNU General Public License v3.0
25.04k stars 1.6k forks source link

Take Screenshot on Gnome without Prompt #2868

Open borgmanJeremy opened 2 years ago

borgmanJeremy commented 2 years ago

Feature Description

This issue is to track updating Flameshot to use the new permission store that was merged into to xdg-desktop-portal: https://github.com/flatpak/xdg-desktop-portal/issues/649#event-7166093739

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

GeorgesStavracas commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

mmahmoudian commented 2 years ago

@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 commented 2 years ago

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

uacode commented 2 years ago

How I can resubmit request for the permission?

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

jerzy-dudzic commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

How to request permissions?

jerzy-dudzic commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

On Mon, 16 Jan 2023, 17:44 Eric Masseran, @.***> wrote:

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 dbusbus = 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

— Reply to this email directly, view it on GitHub https://github.com/flameshot-org/flameshot/issues/2868#issuecomment-1384310540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKNEBR4KSNKIYFVFNO5X5LWSV3HFANCNFSM56IFQHVA . You are receiving this because you are subscribed to this to thread.

Is this the contrived obscure backend script alternative to a "Remember my choice" checkbox that would clearly be an ideal solution/workaround for this scenario or does Gnome only remember if you selected "Deny" and then prompt for permission every time you want to share a screenshot? I am not clear as to the specific "solution" in this case, I'll try to find a moment to test this myself and report back. Clearly either way, this is an issue with Gnome/Wayland rather than Flameshot.

Message ID: @.***>

ttys3 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Hi, please see:

https://github.com/flameshot-org/flameshot/issues/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 commented 1 year ago

@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:

https://github.com/flameshot-org/flameshot/issues/3092#issuecomment-1676291113

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

Tectract commented 11 months ago

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

darkblaze69 commented 10 months ago

this looks irrelevant to modern days

uacode commented 10 months ago

@darkblaze69 Disagree

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

Tectract commented 10 months ago

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 commented 10 months ago

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

lxwulf commented 8 months ago

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

Flameshot

uacode commented 8 months ago

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

lxwulf commented 8 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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

Command: flatpak run org.flameshot.Flameshot gui

Shortcut: Print

lxwulf commented 7 months ago

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.
tao12345666333 commented 2 months ago

Thanks @redsfyre

I like to use the Sakura, so my command is like this.

sakura -c 1 -r 1 -x '/usr/bin/flameshot gui'
lxwulf commented 1 month ago

Update Flatpak version:

Does still not work!

Update RPM version:

Does only work with a custom shortcut, as @rgarrigue already mentioned it.

  1. Set a custom shortcut
  2. For the command, insert: gnome-terminal -- /usr/bin/flameshot gui
  3. Save it
  4. Execute the shortcut
PolyMeilex commented 1 month ago

For Flatpak just run flatpak permission-set screenshot screenshot org.flameshot.Flameshot yes, normally there should be a popup that asks you about this permission, but in Flameshot it does not work (maybe caused by the lack of a typical main window?), so you have to set the permission manually.