flameshot-org / flameshot

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

Hyprland support? #2978

Open quantenzitrone opened 1 year ago

quantenzitrone commented 1 year ago

Flameshot Version

Flameshot v12.1.0 (-) Compiled with Qt 5.15.7

Installation Type

Linux, MacOS, or Windows Package manager (apt, pacman, eopkg, choco, brew, ...)

Operating System type and version

NixOS 22.11pre425156.872fceeed60 (Raccoon)

Description

Flameshot doesn't work on Hyprland (a wayland compositor). With $XDG_CURRENT_DESKTOP set to the default "Hyprland", flameshot says:

~ $ echo $XDG_CURRENT_DESKTOP
Hyprland
~ $ flameshot &
[1] 127966
kf.windowsystem: Could not find any platform plugin
~ $ flameshot full
flameshot: error: Unable to detect desktop environment (GNOME? KDE? Sway? ...)
flameshot: error: Hint: try setting the XDG_CURRENT_DESKTOP environment variable.
flameshot: error: Unable to capture screen
flameshot: info: Screenshot aborted.
~ $

However, when I set the environment variable $XDG_CURRENT_DESKTOP to Sway flameshot just doesn't do anything.

~ $ XDG_CURRENT_DESKTOP=Sway
~ $ echo $XDG_CURRENT_DESKTOP
Sway
~ $ flameshot &
[1] 128100
kf.windowsystem: Could not find any platform plugin
~ $ time flameshot full
^C

real    0m16.907s
user    0m0.145s
sys 0m0.074s
~ $

Steps to reproduce

  1. install hyprland
  2. run flameshot gui

Screenshots or screen recordings

No response

System Information

~ $ inxi --width 80 --system --graphics
System:
  Host: nix Kernel: 6.0.7-zen1 x86_64 bits: 64 Desktop: N/A
  Distro: NixOS 22.11 (Raccoon)
Graphics:
  Message: No device data found.
  Device-1: DGEMU019I992XE HP Wide Vision HD Camera type: USB driver: uvcvideo
  Display: wayland server: X.Org 1.22.1.3 driver: loaded: N/A
  resolution: 1920x1080~60Hz
  OpenGL: renderer: Mesa Intel HD Graphics 630 (KBL GT2) v: 4.6 Mesa 22.2.2
~ $ wlr-randr                                                                                          ✘ 1
eDP-1 "Chimei Innolux Corporation 0x15D3 (eDP-1)"
  Physical size: 340x190 mm
  Enabled: yes
  Modes:
    1920x1080 px, 40.004002 Hz
    1920x1080 px, 60.007999 Hz (preferred, current)
  Position: 0,0
  Transform: normal
  Scale: 1.000000
~ $ lspci | grep -i 'vga\|3d\|2d'
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Mobile] (rev a1)
~ $ lshw -class display
WARNING: you should run this program as super-user.
  *-display
       physical id: 0
       bus info: pci@0000:01:00.0
       version: a1
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list rom
       configuration: driver=nvidia latency=0
       resources: irq:141 memory:b3000000-b3ffffff memory:a0000000-afffffff memory:b0000000-b1ffffff ioport:4000(size=128) memory:b4080000-b40fffff
  *-display
       physical id: 2
       bus info: pci@0000:00:02.0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list rom
       configuration: driver=i915 latency=0
       resources: irq:139 memory:b2000000-b2ffffff memory:c0000000-cfffffff ioport:5000(size=64) memory:c0000-dffff
WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
~ $ uname -a
Linux nix 6.0.7-zen1 #1-NixOS ZEN SMP PREEMPT_DYNAMIC Tue Jan 1 00:00:00 UTC 1980 x86_64 GNU/Linux
Mango0x45 commented 1 year ago

I am experiencing this aswell

mmahmoudian commented 1 year ago

Well, Hyprland looks like a promising WM to replace dwm, so I personally am interested in supporting it. But as far as I can tell it should work if you set it to sway. This is the part that generates the error you observed:

https://github.com/flameshot-org/flameshot/blob/d17eb53816bc572e161714b67de52daf1af23e86/src/utils/screengrabber.cpp#L99-L124

which calls:

https://github.com/flameshot-org/flameshot/blob/d17eb53816bc572e161714b67de52daf1af23e86/src/utils/desktopinfo.cpp#L26-L54

I don't see why it should not work. This needs further investigation.

kyechou commented 1 year ago

@mmahmoudian thanks for the response. I tried running flameshot in one terminal and env XDG_CURRENT_DESKTOP=Sway flameshot gui in another as you mentioned in https://github.com/flameshot-org/flameshot/issues/2351#issuecomment-1038025969. But there is no output messages from either commands at all.

I'm running the latest flameshot (built from the master branch) on Arch Linux's mainline kernel (6.0.8) with Hyprland. Please let me know if there's anything I can help with for the issue.

kyechou commented 1 year ago

@mmahmoudian , it looks like gotSignal is never triggered. The execution gets stuck at this line: https://github.com/flameshot-org/flameshot/blob/d17eb53816bc572e161714b67de52daf1af23e86/src/utils/screengrabber.cpp#L75

kyechou commented 1 year ago

It seems these issues might be related to this one: https://github.com/flameshot-org/flameshot/issues/2872 https://github.com/flatpak/xdg-desktop-portal/issues/861

However the problem exists with xdg-desktop-portal 1.15.0 and the latest commit of xdg-desktop-portal-wlr-git v0.6.0.r3.gc83b3cc-1.

env XDG_CURRENT_DESKTOP=sway XDG_SESSION_DESKTOP=sway QT_QPA_PLATFORM=wayland flameshot gui
dbus-monitor output ```sh $ dbus-monitor --session sender=org.freedesktop.portal.Desktop destination=org.freedesktop.portal.Desktop signal time=1668827818.577499 sender=org.freedesktop.DBus -> destination=:1.172 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired string ":1.172" signal time=1668827818.577593 sender=org.freedesktop.DBus -> destination=:1.172 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost string ":1.172" method call time=1668827823.267767 sender=:1.155 -> destination=:1.174 serial=45 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=GetAll string "org.freedesktop.impl.portal.ScreenCast" method return time=1668827823.267976 sender=:1.174 -> destination=:1.155 serial=4 reply_serial=45 array [ dict entry( string "AvailableSourceTypes" variant uint32 1 ) dict entry( string "AvailableCursorModes" variant uint32 3 ) dict entry( string "version" variant uint32 2 ) ] signal time=1668827823.268794 sender=org.freedesktop.DBus -> destination=:1.155 serial=87 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost string "org.freedesktop.portal.Desktop" method return time=1668827823.268884 sender=org.freedesktop.DBus -> destination=:1.173 serial=41 reply_serial=42 uint32 1 method call time=1668827823.269085 sender=:1.161 -> destination=:1.173 serial=115 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=GetAll string "org.freedesktop.portal.Inhibit" error time=1668827823.269303 sender=:1.173 -> destination=:1.161 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=115 string "No such interface “org.freedesktop.portal.Inhibit”" method call time=1668827830.926087 sender=:1.175 -> destination=org.freedesktop.portal.Desktop serial=2 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=Get string "org.freedesktop.portal.Screenshot" string "version" error time=1668827830.926287 sender=:1.173 -> destination=:1.175 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=2 string "No such interface “org.freedesktop.portal.Screenshot”" method call time=1668827830.962327 sender=:1.175 -> destination=org.freedesktop.portal.Desktop serial=9 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Introspectable; member=Introspect method return time=1668827830.962652 sender=:1.173 -> destination=:1.175 serial=45 reply_serial=9 string " " method call time=1668827830.963884 sender=:1.175 -> destination=org.freedesktop.portal.Desktop serial=16 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot string "" array [ dict entry( string "handle_token" variant string "33d4f6f1d52e4bd697fb7e9cfe8820ad" ) dict entry( string "interactive" variant boolean false ) ] error time=1668827830.964084 sender=:1.173 -> destination=:1.175 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=16 string "No such interface “org.freedesktop.portal.Screenshot” on object at path /org/freedesktop/portal/desktop" method call time=1668827851.236965 sender=:1.177 -> destination=:1.173 serial=19 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=GetAll string "org.freedesktop.portal.Settings" error time=1668827851.237123 sender=:1.173 -> destination=:1.177 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=19 string "No such interface “org.freedesktop.portal.Settings”" method call time=1668827851.237281 sender=:1.177 -> destination=:1.173 serial=20 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Settings; member=Read string "org.freedesktop.appearance" string "color-scheme" error time=1668827851.237366 sender=:1.173 -> destination=:1.177 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=20 string "No such interface “org.freedesktop.portal.Settings” on object at path /org/freedesktop/portal/desktop" method call time=1668827851.691958 sender=:1.177 -> destination=:1.173 serial=31 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Settings; member=Read string "org.freedesktop.appearance" string "color-scheme" error time=1668827851.692161 sender=:1.173 -> destination=:1.177 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=31 string "No such interface “org.freedesktop.portal.Settings” on object at path /org/freedesktop/portal/desktop" ```
xdg-desktop-portal output ```sh $ /usr/lib/xdg-desktop-portal --replace --verbose XDP: load portals from /usr/share/xdg-desktop-portal/portals XDP: loading /usr/share/xdg-desktop-portal/portals/gnome-keyring.portal XDP: portal implementation for gnome XDP: portal implementation supports org.freedesktop.impl.portal.Secret XDP: loading /usr/share/xdg-desktop-portal/portals/wlr.portal XDP: portal implementation for wlroots, sway, Wayfire, river, phosh, Hyprland XDP: portal implementation supports org.freedesktop.impl.portal.Screenshot XDP: portal implementation supports org.freedesktop.impl.portal.ScreenCast XDP: providing portal org.freedesktop.portal.MemoryMonitor XDP: providing portal org.freedesktop.portal.PowerProfileMonitor XDP: providing portal org.freedesktop.portal.NetworkMonitor XDP: providing portal org.freedesktop.portal.ProxyResolver XDP: providing portal org.freedesktop.portal.Trash XDP: providing portal org.freedesktop.portal.GameMode XDP: providing portal org.freedesktop.portal.Realtime ** (/usr/lib/xdg-desktop-portal:40676): WARNING **: 21:17:03.227: No skeleton to export XDP: Using wlr.portal for org.freedesktop.impl.portal.Screenshot in Hyprland XDP: Falling back to gnome-keyring.portal for org.freedesktop.impl.portal.Secret XDP: providing portal org.freedesktop.portal.Secret XDP: Using wlr.portal for org.freedesktop.impl.portal.ScreenCast in Hyprland XDP: providing portal org.freedesktop.portal.ScreenCast XDP: org.freedesktop.portal.Desktop acquired ```

Edit: Make a clean, reinstalled setup and update the command output.

kyechou commented 1 year ago

According to https://github.com/flameshot-org/flameshot/issues/2872, I tested flameshot with the downgraded xdg-desktop-portal 1.14.6, and it works flawlessly on both Hyprland and Sway. With the updated xdg-desktop-portal and xdg-desktop-portal-wlr, the behavior is as described in https://github.com/flameshot-org/flameshot/issues/2959.

~I'm not sure if this is an upstream issue, and I'm also not familiar with the code enough to know what to report upstream.~

Either way, I think this issue is very likely to be the same as https://github.com/flameshot-org/flameshot/issues/2959, except that it requires the environment variables env XDG_CURRENT_DESKTOP=sway XDG_SESSION_DESKTOP=sway QT_QPA_PLATFORM=wayland to run on Hyprland. But that should be relatively easier to fix by adding a few conditionals as indicated by @mmahmoudian https://github.com/flameshot-org/flameshot/issues/2978#issuecomment-1312831336.

Edit: Attach the working screenshot with the downgraded xdg-desktop-portal 1.14.6 Edit 2: Reported here https://github.com/emersion/xdg-desktop-portal-wlr/issues/246

Screenshot ![2022-11-18_21-08](https://user-images.githubusercontent.com/11006026/202832474-24c3865b-44fb-4929-ab6b-a9ad00e8cc68.png)
Phundrak commented 1 year ago

As mentioned in #2872, I tested flameshot with the downgraded xdg-desktop-portal 1.14.6, and it works flawlessly on both Hyprland and Sway. With the updated xdg-desktop-portal and xdg-desktop-portal-wlr, the behavior is as described in #2959.

This is not related to Hyprland itself, but I have the same results with newm: with xdg-desktop-portal 1.14.6, Flameshot also works great (except it doesn’t go fullscreen on its own, but I think that’s specific to newm). But with 1.15.0, it doesn’t work anymore with seemingly the same issues.

quantenzitrone commented 1 year ago

It doesn't work with xdg-desktop-portal 1.14.6 for me either.

~ $ systemctl --user status xdg-desktop-portal                                                                                                                                                                      ✘ 130
● xdg-desktop-portal.service - Portal service
     Loaded: loaded (/etc/systemd/user/xdg-desktop-portal.service; static)
     Active: active (running) since Thu 2022-11-24 07:16:40 CET; 48s ago
   Main PID: 2523 (.xdg-desktop-po)
      Tasks: 6 (limit: 19048)
     Memory: 3.2M
        CPU: 46ms
     CGroup: /user.slice/user-1000.slice/user@1000.service/session.slice/xdg-desktop-portal.service
             └─2523 /nix/store/28j9l7j502rd8qgdbxc8bmgsrzqvhrd2-xdg-desktop-portal-1.14.6/libexec/xdg-desktop-portal

Nov 24 07:16:40 nix systemd[1426]: Starting Portal service...
Nov 24 07:16:40 nix systemd[1426]: Started Portal service.
~ $ export XDG_CURRENT_DESKTOP=sway
~ $ echo $XDG_CURRENT_DESKTOP
sway
~ $ time flameshot gui                                                                                                                                                                                              ✘ 130
kf.windowsystem: Could not find any platform plugin
^C
________________________________________________________
Executed in   29.34 secs      fish           external
   usr time  137.58 millis    0.00 millis  137.58 millis
   sys time   72.05 millis    1.75 millis   70.30 millis

see flameshot still doesn't do anything is anyone else here on NixOS?

blurgyy commented 1 year ago

Hi @Quantenzitrone, I'm not entirely sure but you might also want to set XDG_CURRENT_DESKTOP to sway for the xdg-desktop-portal service.

The official home-manager module provided by hyprland imports the environments in the very first line of hyprland's config file, and XDG_CURRENT_DESKTOP is hard-coded to Hyprland in hyprland's code.

I ended up with patching Hyprland to set XDG_CURRENT_DESKTOP to sway, in paticular this line https://github.com/hyprwm/Hyprland/blob/f6067816fb2bbd7dc9a00da6391cc6dcf5991035/src/Compositor.cpp#L342

adamant-pwn commented 1 year ago

Installing xdg-desktop-portal-git, xdg-desktop-portal-wlr-git and xdg-desktop-portal-gtk-git from AUR, and using XDG_CURRENT_DESKTOP=sway seems to fix the issue for me.

mmahmoudian commented 1 year ago

@adamant-pwn which versions?

erikdubois commented 1 year ago

Like @adamant-pwn I have all the packages installed. But when our XDG_CURRENT_DESKTOP=Hyprland is on we will not have a screenshot from flameshot When we change it (export ... sway) then it works again so my suggestion would be

whatever you do to make it work in sway do exactly the same thing if you find out that you are on Hyprland my two cents

flameshot-git on ArchLinux/ArcoLinux version r1858.b4300d30-1

mmahmoudian commented 1 year ago

@erikdubois Thanks for your comment 🍻 . As I briefly touched upon before, adding hyprland (which I'm also getting into as well and loving it) is relatively easy, but the part about "downgrading xdg-desktop-portal to 1.14.6" as reported by users [1, 2] is the tricky part.

Can confirm that your observation about setting the environmental variable (XDG_CURRENT_DESKTOP=sway) has worked with the latest xdg-desktop-portal (version 1.15.0-1 at the time of writing this)?

erikdubois commented 1 year ago

That is exactly the version I use now.

It feels like this could be an easy win.

Do the same as on Sway but start with a different XDG_CURRENT_DESKTOP

Hex5DA commented 1 year ago

are there any fixes for this at present (packages to install, ect.) or is this still under-progress?

kyechou commented 1 year ago

Hi @onlyTr3v0r, Apart from adding the additional conditional for Hyprland in flameshot (https://github.com/flameshot-org/flameshot/issues/2978#issuecomment-1312831336), the core issue with xdg-desktop-portal-wlr was reported upstream (https://github.com/emersion/xdg-desktop-portal-wlr/issues/246), and I believe both are still under progress.

mmahmoudian commented 1 year ago

We already have a PR that addresses the Flameshot related part. That PR is under review and will be merged soon.

I would like to also encourage you all to read the open PRs and help us reviewing them. It would help us tremendously. Even if you don't know C++, finding a typo would be a great help.

kyechou commented 1 year ago

We already have a PR that address the Flameshot related part. That PR is under review and will be merged soon.

Add a link to the PR: https://github.com/flameshot-org/flameshot/pull/3018

ghost commented 1 year ago

hyprland released own fork of xdg-desktop-portal-wlr. This fork supports window capture https://github.com/hyprwm/xdg-desktop-portal-hyprland

nothankyouzzz commented 1 year ago

Unfortunately, it also didn't work for me, though I install xdg-desktop-portal-hyprland-git.

hyprland released own fork of xdg-desktop-portal-wlr. This fork supports window capture https://github.com/hyprwm/xdg-desktop-portal-hyprland

erikdubois commented 1 year ago

We have a working flameshot-tray that lets us take pictures on Hyprland. We let Flameshot believe it is on Sway.

I can only repeat what I have said earlier last month. https://github.com/flameshot-org/flameshot/issues/2978#issuecomment-1337645101

Here you see how we made it work on ArcoLinux. https://youtu.be/skHFa0rPZFk

if [ -f /usr/share/applications/org.flameshot.Flameshot.desktop ]; then FIND="Exec=\/usr\/bin\/flameshot" REPLACE="Exec=env XDG_CURRENT_DESKTOP=sway \/usr\/bin\/flameshot" sudo sed -i "s/$FIND/$REPLACE/g" /usr/share/applications/org.flameshot.Flameshot.desktop fi

DexterHaxxor commented 1 year ago

What's the status on this? I know it works if I force it to think I'm on Sway, but that seems unnecessary. EDIT: To be specific, it works the first time, then I have to log out and log back in, then it works again.

mmahmoudian commented 1 year ago

@DexterHaxxor The status is that someone need to invest a bit of time to do this. I personally haven't found some time to implement and test. The solution @erikdubois provided is a quick nice hack for now, but we need to either add hyprland explecitly, or find a way to bundle multiple Wayland WMs with some sort of auto-discovery or default fallback. This should be explored

mmahmoudian commented 1 year ago

The #3018 have added support for hyprland and grim. This of course needs to be tested. There is a chance that you need to use -DUSE_WAYLAND_GRIM=true for cmake and build it again. We are in the process of discussion about how to add this to AUR, but any suggestions/input/feedback is welcome.

emrakyz commented 1 year ago

@mmahmoudian I have tried it and had problems. I am on Gentoo / Hyprland / 6.2 Kernel so I had all dependencies. I just removed Flameshot that is from the package manager.

Steps: 1- Git clone the repository. 2- mkdir build cd build cmake -DUSE_WAYLAND_GRIM=true ../ make 3- $ flameshot gui

Problems: 1- After trying "flameshot gui", the screen zooms and the resolution drops. 2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Bvngee commented 1 year ago

Problems: 1- After trying "flameshot gui", the screen zooms and the resolution drops. 2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Can confirm. Not entirely sure about the first issue you mentioned (might just be misunderstanding it), but I am definitely getting the lag. The interesting thing is, this behavior seems to be the same for me with and without the flag USE_WAYLAND_GRIM=true, The lag happened without, and gave the warning to recompile, and then happened seemingly the same with, and gave me the warning about grim's screenshot component being implemented based on wlroots etc etc, as per screengrabber.cpp. Here's a video, in case it helps.

emrakyz commented 1 year ago

@BvngeeCord Hi! The first issue might have been because of the scaling. I can't screenshot the whole screen with flameshot. After prompt, I can only see and select a part of my screen and that doesn't look clear; it's blurry. The second problem is the same you have in the video but the difference is that I couldn't get it to work without USE_WAYLAND_GRIM=true.

Hyplrland config: monitor=DP-1,2560x1440@165,auto,2

Bvngee commented 1 year ago

Ah, the zooming is definitely a scaling issue then, as I'm not doing any. My config is monitor=DP-1,2560x1440@75,2560x0,1 monitor=DP-2,2560x1440@75,0x0,1, but it occurred when I switched to a value other than 1. Flameshot also seems to like defaulting to DP-1, although that could be completely unrelated?

ardishko commented 1 year ago

The #3018 have added support for hyprland and grim. This of course needs to be tested. There is a chance that you need to use -DUSE_WAYLAND_GRIM=true for cmake and build it again. We are in the process of discussion about how to add this to AUR, but any suggestions/input/feedback is welcome.

taking a look at https://aur.archlinux.org/flameshot-git.git could be helpful..

ardishko commented 1 year ago

Wait, that's your package...Okay...

coffebar commented 1 year ago

REPLACE="Exec=env XDG_CURRENT_DESKTOP=sway /usr/bin/flameshot"

for me, changing XDG_CURRENT_DESKTOP to sway not making flameshot to work on Hyprland

unitythemaker commented 1 year ago

REPLACE="Exec=env XDG_CURRENT_DESKTOP=sway /usr/bin/flameshot"

for me, changing XDG_CURRENT_DESKTOP to sway not making flameshot to work on Hyprland

Me too, it just hangs. However in dbus-monitor I can see the following:

dbus-monitor --session sender=org.freedesktop.portal.Desktop destination=org.freedesktop.portal.Desktop
...[other log messages]...
   string "Allow Applications to Take Screenshots?"
   string "An application wants to be able to take screenshots at any time."
   string "This permission can be changed at any time from the privacy settings."
...[continuation of the message]...
standard3 commented 1 year ago

Still not working by passing environment variable, it just hangs...

$ env XDG_CURRENT_DESKTOP=sway flameshot full

Tried debugging through dbus-monitor too :

$ dbus-monitor --session sender=org.freedesktop.portal.Desktop destination=org.freedesktop.portal.Desktop
...

method call time=1678906922.996473 sender=:1.884 -> destination=org.freedesktop.portal.Desktop serial=2 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=Get
   string "org.freedesktop.portal.Screenshot"
   string "version"
error time=1678906922.996574 sender=:1.328 -> destination=:1.884 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=2
   string "No such interface “org.freedesktop.portal.Screenshot”"
method call time=1678906923.021918 sender=:1.884 -> destination=org.freedesktop.portal.Desktop serial=9 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Introspectable; member=Introspect
method return time=1678906923.022097 sender=:1.328 -> destination=:1.884 serial=73 reply_serial=9
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

...

method call time=1678906923.022923 sender=:1.884 -> destination=org.freedesktop.portal.Desktop serial=16 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.Screenshot; member=Screenshot
   string ""
   array [
      dict entry(
         string "handle_token"
         variant             string "813e52894d8745b3a2785bcd85cb8287"
      )
      dict entry(
         string "interactive"
         variant             boolean false
      )
   ]
error time=1678906923.023028 sender=:1.328 -> destination=:1.884 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=16
   string "No such interface “org.freedesktop.portal.Screenshot” on object at path /org/freedesktop/portal/desktop"
vec715 commented 1 year ago

any updates?

mmahmoudian commented 1 year ago

@cynikkk

Still not working by passing environment variable, it just hangs...

You don't need to set environmental variable anymore if you have the latest commits

@vec715 Read this from 25 days ago: https://github.com/flameshot-org/flameshot/issues/2978#issuecomment-1436715162

TaPO4eg3D commented 1 year ago

2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Can confirm that region selection is extremely slow. Everything (hyprland, xdg-desktop-portal-hyprland, grim, flameshot) is built from source. Flameshot is built with USE_WAYLAND_GRIM=1

tchofy commented 1 year ago

2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Can confirm that region selection is extremely slow. Everything (hyprland, xdg-desktop-portal-hyprland, grim, flameshot) is built from source. Flameshot is built with USE_WAYLAND_GRIM=1

I've had some success by forcing it to run through xwayland with QT_QPA_PLATFORM=xcb flameshot and somehow it works, but it breaks keyboard shortcuts because it complains about losing focus. Might be able to work around it with hyprland's pass dispatcher, haven't tested it yet.

standard3 commented 1 year ago

2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Can confirm that region selection is extremely slow. Everything (hyprland, xdg-desktop-portal-hyprland, grim, flameshot) is built from source. Flameshot is built with USE_WAYLAND_GRIM=1

I've had some success by forcing it to run through xwayland with QT_QPA_PLATFORM=xcb flameshot and somehow it works, but it breaks keyboard shortcuts because it complains about losing focus. Might be able to work around it with hyprland's pass dispatcher, haven't tested it yet.

⋊> ~ flameshot --version
Flameshot v12.1.0 (3ededae5)
Compiled with Qt 5.15.8

Tried compiling it with USE_WAYLAND_GRIM=1, ran with QT_QPA_PLATFORM=xcb flameshot and got the focus issue too.

ardishko commented 1 year ago

2- It's lagging too much. The selection is extremely slow. I select somewhere on my screen and it's getting selected in 15 seconds.

Can confirm that region selection is extremely slow. Everything (hyprland, xdg-desktop-portal-hyprland, grim, flameshot) is built from source. Flameshot is built with USE_WAYLAND_GRIM=1

I've had some success by forcing it to run through xwayland with QT_QPA_PLATFORM=xcb flameshot and somehow it works, but it breaks keyboard shortcuts because it complains about losing focus. Might be able to work around it with hyprland's pass dispatcher, haven't tested it yet.

I have this issue on Sway and Hyprland, seems this is not a Hyprland issue but rather more so a problem with the program itself. I remember making it work completely fine on Sway before (somehow, miraculously) the program was updated to not require certain env-vars to be set to sway, so this is an implementation issue.

emrakyz commented 1 year ago

@mmahmoudian Update after four months. Using Linux 6.2.9 kernel; latest git versions of Hyprland, xdg-desktop-portal-hyprland, wlroots, wayland, wayland-protocols, wayland-scanners, grim and slurp. I also have latest versions of qt5 and qt6. I enabled use-wayland-grim.

https://user-images.githubusercontent.com/89175311/231425119-6a8edc5b-c170-4a9c-96c0-016d8788bfd5.mp4

mmahmoudian commented 1 year ago

@emrakyz I have personally experienced that issue only on KDE Plasma Wayland. I think we have a regression somewhere. This needs to be investigated.

Update: I just tried it on hyprland (latest of everything) and compiled flameshot head with cmake ../ -DUSE_WAYLAND_GRIM=true and I observed a few millisecond lag, but not much to be disturbing or noticable

hyprland                                  0.23.0beta-4                  community  4,1 MB
xdg-desktop-portal                        1.16.0-1                      extra      2,1 MB
xdg-desktop-portal-kde                    5.27.4.1-1                    extra      1,0 MB
xdg-desktop-portal-wlr                    0.6.0-1                       community  104,1 kB
grim                                      1.4.0-3                       community  37,3 kB
wayland                                   1.22.0-1                      extra      820,0 kB
wayland-protocols                         1.31-1                        extra      509,4 kB
plasma-wayland-session                    5.27.4.1-1                    extra      3,5 kB
qt5-wayland                               5.15.8+kde+r63-1              extra      6,4 MB
qt6-wayland                               6.4.3-1                       extra      6,8 MB
bemenu-wayland                            0.6.14-1                      community  55,4 kB
emrakyz commented 1 year ago

@mmahmoudian

Hyprland uses own implementation for xdg-desktop-portal called "xdg-desktop-portal-hyprland". It's also recommended to remove other implementations such as -kde and -wlr.

Is it possible that we have that problem because of Nvidia GPU? But I have no problem with Grim+Slurp or video recording.

Plus, the scaling also have issues as you can see in the video. It zooms when I start flameshot.

I definitely feel the lack of Flameshot :)

mmahmoudian commented 1 year ago

Hyprland uses own implementation for xdg-desktop-portal called "xdg-desktop-portal-hyprland".

Thanks for the notice. I know that hyprland has their fork of xdg-desktop-portal-wlr , but while testing, I removed it and installed the xdg-desktop-portal-wlr and it didn't change the situation, so I reported the last state. About the xdg-desktop-portal-kde, I have it because of KDE Plasma.

Is it possible that we have that problem because of Nvidia GPU?

I don't think that is the issue. As I said, I also face the same laggy behavior in KDE Plasma Wayland (it was in Intel GPU).

Plus, the scaling also have issues as you can see in the video. It zooms when I start flameshot.

I have not experience that on hyprland or plasma. Do you have fractional scaling? Or do you have multiple monitors?

I definitely feel the lack of Flameshot :)

Thanks. This issue needs to be addressed, but we are severely short-staffed. One of our two main devs left the project due to burn-out, and the other one is also very busy with personal life and his job. We have asked numerous times from the community to join the project as devs, but no one stepped up. Basically I am trying to keep the lights on at this point.

Apart from this short frustraited rant😅, as always any contribution is very welcome. Even if it means fixing a typo, or telling others who want to challenge their C++ skills.

emrakyz commented 1 year ago

Do you have fractional scaling? Or do you have multiple monitors?

I have fractional scaling enabled on hypr.conf: monitor=DP-1,2560x1440@165,auto,2

I have tried different qt environment variables but that didn't change it. If I set qt env like this, QT_SCREEN_SCALE_FACTOR=0.5 it seems to work but, since it lags I can not be sure it's working normally.

Basically I am trying to keep the lights on at this point.

It's surprising because, I have never seen a project even close to what Flameshot achieved. All functions you need from a screenshot tool without bloat; working cross platform; fully free and open source. Thanks for your work! I will try to inform more people.

There is also a possibility that since Flameshot normally is a very stable and completed program, there is not much to extend or improve in general meaning. So less people are interested. As Wayland has lots of problems for now, with the increased use of Wayland compositors, these issues will probably be addressed.

Btw, is there a way to compile Flameshot with Qt6 directly? I have both versions and I only used two cmake configs: USE_WAYLAND_CLIPBOARD USE_WAYLAND_GRIM

mmahmoudian commented 1 year ago

There is also a possibility that since Flameshot normally is a very stable and completed program, there is not much to extend or improve in general meaning. So less people are interested. As Wayland has lots of problems for now, with the increased use of Wayland compositors, these issues will probably be addressed.

We need to still push for three things:

  1. the plugin
  2. Wayland support
  3. Windows CLI

Some people have shown interest in implementing the plugin system, and even one of Flameshot devs is having a branch on his fork for this. But it is still far from anything tangible as far as I know.

Wayland is a big issue especially when we get certain "opinionated" attitude from some devs (e.g Gnome folks who gave us a veeeeery hard time and practically caused burn-out).

Another dev was from Ukraine and, understandably, due to the war they have been focusing on real-life matters.

Btw, is there a way to compile Flameshot with Qt6 directly?

I know that the former main dev of Flameshot was at some point actively pushing to port it for Qt6, but that branch didn't get pushed up-stream. Perhaps it can be forked.

jokeyrhyme commented 1 year ago

New release for xdg-desktop-portal-wlr: https://github.com/emersion/xdg-desktop-portal-wlr/releases/tag/v0.7.0

add Hyprland to wlr.portal

https://github.com/emersion/xdg-desktop-portal-wlr/blob/master/wlr.portal#L4

That means that when xdg-desktop-portal reads XDG_CURRENT_DESKTOP=Hyprland, it will know that xdg-desktop-portal-wlr is compatible and will automatically start it if necessary and send ScreenCast and Screenshot requests to it

mmahmoudian commented 1 year ago

I updated the AUR and I just confirmed that the AUR now out of the box works just fine on Hyprland.

@erikdubois would it be possible for you to also confirm this?

erikdubois commented 1 year ago

yes it works to make a picture with the last code on github It now also understands what screen to take a picture from (dual screen here).

But the button to copy/paste does not work yet.

I solved that like this - https://github.com/erikdubois/pkgbuild/blob/2d8ae6cb088798325d0d8c4fa1c9798deb0ef92d/edu-flameshot-git/PKGBUILD#L94

and

we add something to the .desktop file to take x11

echo
echo "Changing flameshot"
echo
if [ -f /usr/share/applications/org.flameshot.Flameshot.desktop ]; then
    FIND="Exec=\/usr\/bin\/flameshot"
    REPLACE="Exec=\/usr\/bin\/env GDK_BACKEND=x11 \/usr\/bin\/flameshot"
    sudo sed -i "s/$FIND/$REPLACE/g" /usr/share/applications/org.flameshot.Flameshot.desktop
fi

https://youtu.be/j7ObpVlz_Vk

mmahmoudian commented 1 year ago

@erikdubois Thanks. Yes for the clipboard flag I did the same some days ago:

https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=flameshot-git#n94

and as far as I can tell, the clipboard is already very functional on hyprland. The only caveat is that on my machine it is very slow (maybe I should reboot), and tit takes about 20 seconds from the time I tell it to copy until the time that it is fully copied. For instance, I could easily paste it with correct dimension and resolution in Inkscape. also this slowness does not change whether I start the daemon and then the gui or I just call it.

About that flag you are setting in the .desktop file, I should say that it has one caveat: it does not work if someone call the daemon or other flameshot subcommands. That environmental variable only will be set if and only if the .desktop file is used.

We for sure need to improve Flameshot to be more compatible with wlroot and wayland in general.

Do you think this issue can be closed?

emrakyz commented 1 year ago

@mmahmoudian

Hi! I have solved two problems by: 1. The lagging problem is solved by the pull request #3059 2. The scaling problem can be solved according to your scaling ratio. In my case scaling is 2.0 so;

Now I got only these problems left (These problems also happened before the two problems fixed):

Environment: