flameshot-org / flameshot

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

ubuntu 24.04 , not able to use the shortcut key to call flameshot for taking screenshots. #3712

Open changchichung opened 3 months ago

changchichung commented 3 months ago

Flameshot Version

flameshot -v Flameshot v12.1.0 (Debian 12.1.0-2build2) Compiled with Qt 5.15.12

Installation Type

apt

Operating System type and version

ubuntu 24.04.1 Desktop

Description

I've been using a custom shortcut key, Ctrl+1, to call the "flameshot gui" command for taking screenshots on Ubuntu 22.04.

Recently, I upgraded to Ubuntu 22.04.1 and reinstalled my laptop. I tried to set up the same custom shortcut key for flameshot, but it's not working and I'm getting an error. I tried manually running "flameshot gui" in the terminal window, and it worked fine.

I then checked the /var/log/syslog file and found an error message when trying to use the shortcut key

2024-09-02T13:59:58.348562+08:00 chchang-ThinkPad-T470p systemd[2202]: Started app-gnome-flameshot-852640.scope - Application launched by gsd-media-keys.
2024-09-02T13:59:58.503497+08:00 chchang-ThinkPad-T470p xdg-desktop-por[4074]: Failed to associate portal window with parent window 
2024-09-02T13:59:58.504938+08:00 chchang-ThinkPad-T470p xdg-desktop-por[3919]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2024-09-02T13:59:58.520813+08:00 chchang-ThinkPad-T470p flameshot[852640]: flameshot: error: Unable to capture screen
2024-09-02T13:59:58.529360+08:00 chchang-ThinkPad-T470p flameshot[852640]: flameshot: error: Unable to capture screen
2024-09-02T13:59:58.600501+08:00 chchang-ThinkPad-T470p flameshot[852640]: flameshot: info: Screenshot aborted.

Steps to reproduce

No response

Screenshots or screen recordings

No response

System Information

  1. ubuntu 24.04.1
  2. monitor
  3. wayland , GNOME 46
zhuangweiji commented 3 months ago

The system prompted me to update to Ubuntu 24.04.1 LTS. After the update, I can normally use flameshot gui in the command line.

However, I cannot use the shortcut key. image image

I have already bound flameshot gui to Alt + A in Settings > Keyboard > View and Customise Shortcuts > Custom shortcuts.

image

the /var/log/syslog file:

2024-09-02T18:25:56.414396+08:00 HP-680 systemd[3262]: Started app-gnome-flameshot-9041.scope - Application launched by gsd-media-keys.
2024-09-02T18:25:56.479808+08:00 HP-680 xdg-desktop-por[4183]: Failed to associate portal window with parent window 
2024-09-02T18:25:56.480580+08:00 HP-680 xdg-desktop-por[4095]: Failed to show access dialog: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Only the focused app is allowed to show a system access dialog
2024-09-02T18:25:56.489617+08:00 HP-680 flameshot[9041]: flameshot: error: Unable to capture screen
2024-09-02T18:25:56.495023+08:00 HP-680 flameshot[9041]: flameshot: error: Unable to capture screen
2024-09-02T18:25:56.579197+08:00 HP-680 flameshot[9041]: flameshot: info: Screenshot aborted.
NerijusNoreika commented 2 months ago

Have the same error as the comment above.

roland-ewald commented 2 months ago

Same here; see also this discussion: https://github.com/flatpak/xdg-desktop-portal/issues/1070

This comment provides a nice workaround (TLDR, QT_QPA_PLATFORM=wayland is required as environment variable for the shortcut to work, so you have to wrap the call into a one-liner script and configure that as custom shortcut): https://github.com/flatpak/xdg-desktop-portal/issues/1070#issuecomment-1771302632

fedelmar commented 2 months ago

Have you try this solution?

https://github.com/flameshot-org/flameshot/issues/3498#issuecomment-2026731686

EnverOsmanov commented 2 months ago

Same here; see also this discussion: flatpak/xdg-desktop-portal#1070

This comment provides a nice workaround (TLDR, QT_QPA_PLATFORM=wayland is required as environment variable for the shortcut to work, so you have to wrap the call into a one-liner script and configure that as custom shortcut): flatpak/xdg-desktop-portal#1070 (comment)

My environment variable is set to "QT_QPA_PLATFORM=wayland;xcb", it was needed for some other app (I think it's qBittorrent). That's why flameshot was still not working.

Running flameshot with own variable worked:

QT_QPA_PLATFORM=wayland flameshot
ilhamwahyu-ni commented 2 months ago

temporary solution, you can use a bash shell script, here I named bash "ss.sh"

and the keyboard buttons work...

image

image chmod +x ./ss.sh

image

Ubuntu 20.04

mca-gif commented 2 months ago

Without creating additional files, this can be done directly from the Gnome Keyboard Custom Shortcuts configuration by setting the command to sh -c "QT_QPA_PLATFORM=wayland flameshot gui"

This has been tested with Ubuntu 24.04 with flameshot installed via the repositories.

image

x-dl commented 1 month ago

Without creating additional files, this can be done directly from the Gnome Keyboard Custom Shortcuts configuration by setting the command to sh -c "QT_QPA_PLATFORM=wayland flameshot gui"

This has been tested with Ubuntu 24.04 with flameshot installed via the repositories.

image

thank you bro , it solves my problem , its very nice of you ,thank you

richecr commented 1 week ago

temporary solution, you can use a bash shell script, here I named bash "ss.sh"

and the keyboard buttons work...

image

image chmod +x ./ss.sh

image

Ubuntu 20.04

Thank you, it worked perfectly