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

Hyprland support? #2978

Open
quantenzitrone opened this issue Nov 12, 2022 · 153 comments
Open

Hyprland support? #2978

quantenzitrone opened this issue Nov 12, 2022 · 153 comments
Assignees
Labels
Unconfirmed Bug The bug is not confirmed by anyone else. Wayland Wayland specific issues

Comments

@quantenzitrone
Copy link

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
@quantenzitrone quantenzitrone added the Unconfirmed Bug The bug is not confirmed by anyone else. label Nov 12, 2022
@Mango0x45
Copy link

I am experiencing this aswell

@mmahmoudian
Copy link
Member

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:

if (m_info.waylandDetected()) {
QPixmap res;
// handle screenshot based on DE
switch (m_info.windowManager()) {
case DesktopInfo::GNOME:
case DesktopInfo::KDE:
case DesktopInfo::QTILE:
case DesktopInfo::SWAY: {
freeDesktopPortal(ok, res);
break;
}
default:
ok = false;
AbstractLogger::error()
<< tr("Unable to detect desktop environment (GNOME? KDE? "
"Qile? Sway? ...)");
AbstractLogger::error()
<< tr("Hint: try setting the XDG_CURRENT_DESKTOP environment "
"variable.");
break;
}
if (!ok) {
AbstractLogger::error() << tr("Unable to capture screen");
}
return res;
}

which calls:

DesktopInfo::WM DesktopInfo::windowManager()
{
DesktopInfo::WM res = DesktopInfo::OTHER;
QStringList desktops = XDG_CURRENT_DESKTOP.split(QChar(':'));
for (auto& desktop : desktops) {
if (desktop.contains(QLatin1String("GNOME"), Qt::CaseInsensitive)) {
return DesktopInfo::GNOME;
}
if (desktop.contains(QLatin1String("qtile"), Qt::CaseInsensitive)) {
return DesktopInfo::QTILE;
}
if (desktop.contains(QLatin1String("sway"), Qt::CaseInsensitive)) {
return DesktopInfo::SWAY;
}
if (desktop.contains(QLatin1String("kde-plasma"))) {
return DesktopInfo::KDE;
}
}
if (!GNOME_DESKTOP_SESSION_ID.isEmpty()) {
return DesktopInfo::GNOME;
}
if (!KDE_FULL_SESSION.isEmpty()) {
return DesktopInfo::KDE;
}
return res;
}

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

@mmahmoudian mmahmoudian added the Wayland Wayland specific issues label Nov 13, 2022
@kyechou
Copy link

kyechou commented Nov 13, 2022

@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 #2351 (comment). 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
Copy link

kyechou commented Nov 13, 2022

@mmahmoudian , it looks like gotSignal is never triggered. The execution gets stuck at this line:

@kyechou
Copy link

kyechou commented Nov 13, 2022

It seems these issues might be related to this one:
#2872
flatpak/xdg-desktop-portal#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
$ 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 "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
                      "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!-- GDBus 2.74.1 -->
<node>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg type="s" name="interface_name" direction="in"/>
      <arg type="s" name="property_name" direction="in"/>
      <arg type="v" name="value" direction="out"/>
    </method>
    <method name="GetAll">
      <arg type="s" name="interface_name" direction="in"/>
      <arg type="a{sv}" name="properties" direction="out"/>
    </method>
    <method name="Set">
      <arg type="s" name="interface_name" direction="in"/>
      <arg type="s" name="property_name" direction="in"/>
      <arg type="v" name="value" direction="in"/>
    </method>
    <signal name="PropertiesChanged">
      <arg type="s" name="interface_name"/>
      <arg type="a{sv}" name="changed_properties"/>
      <arg type="as" name="invalidated_properties"/>
    </signal>
  </interface>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg type="s" name="xml_data" direction="out"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Peer">
    <method name="Ping"/>
    <method name="GetMachineId">
      <arg type="s" name="machine_uuid" direction="out"/>
    </method>
  </interface>
  <interface name="org.freedesktop.portal.Trash">
    <method name="TrashFile">
      <arg type="h" name="fd" direction="in"/>
      <arg type="u" name="result" direction="out"/>
    </method>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.MemoryMonitor">
    <signal name="LowMemoryWarning">
      <arg type="y" name="level"/>
    </signal>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.GameMode">
    <method name="QueryStatus">
      <arg type="i" name="pid" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="RegisterGame">
      <arg type="i" name="pid" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="UnregisterGame">
      <arg type="i" name="pid" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="QueryStatusByPid">
      <arg type="i" name="target" direction="in"/>
      <arg type="i" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="RegisterGameByPid">
      <arg type="i" name="target" direction="in"/>
      <arg type="i" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="UnregisterGameByPid">
      <arg type="i" name="target" direction="in"/>
      <arg type="i" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="QueryStatusByPIDFd">
      <arg type="h" name="target" direction="in"/>
      <arg type="h" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="RegisterGameByPIDFd">
      <arg type="h" name="target" direction="in"/>
      <arg type="h" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <method name="UnregisterGameByPIDFd">
      <arg type="h" name="target" direction="in"/>
      <arg type="h" name="requester" direction="in"/>
      <arg type="i" name="result" direction="out"/>
    </method>
    <property type="b" name="Active" access="read"/>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.ProxyResolver">
    <method name="Lookup">
      <arg type="s" name="uri" direction="in"/>
      <arg type="as" name="proxies" direction="out"/>
    </method>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.NetworkMonitor">
    <method name="GetAvailable">
      <arg type="b" name="available" direction="out"/>
    </method>
    <method name="GetMetered">
      <arg type="b" name="metered" direction="out"/>
    </method>
    <method name="GetConnectivity">
      <arg type="u" name="connectivity" direction="out"/>
    </method>
    <method name="GetStatus">
      <arg type="a{sv}" name="status" direction="out"/>
    </method>
    <method name="CanReach">
      <arg type="s" name="hostname" direction="in"/>
      <arg type="u" name="port" direction="in"/>
      <arg type="b" name="reachable" direction="out"/>
    </method>
    <signal name="changed"/>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.Secret">
    <method name="RetrieveSecret">
      <arg type="h" name="fd" direction="in"/>
      <arg type="a{sv}" name="options" direction="in"/>
      <arg type="o" name="handle" direction="out"/>
    </method>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.ScreenCast">
    <method name="CreateSession">
      <arg type="a{sv}" name="options" direction="in"/>
      <arg type="o" name="handle" direction="out"/>
    </method>
    <method name="SelectSources">
      <arg type="o" name="session_handle" direction="in"/>
      <arg type="a{sv}" name="options" direction="in"/>
      <arg type="o" name="handle" direction="out"/>
    </method>
    <method name="Start">
      <arg type="o" name="session_handle" direction="in"/>
      <arg type="s" name="parent_window" direction="in"/>
      <arg type="a{sv}" name="options" direction="in"/>
      <arg type="o" name="handle" direction="out"/>
    </method>
    <method name="OpenPipeWireRemote">
      <arg type="o" name="session_handle" direction="in"/>
      <arg type="a{sv}" name="options" direction="in"/>
      <arg type="h" name="fd" direction="out"/>
    </method>
    <property type="u" name="AvailableSourceTypes" access="read"/>
    <property type="u" name="AvailableCursorModes" access="read"/>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.PowerProfileMonitor">
    <property type="b" name="power-saver-enabled" access="read"/>
    <property type="u" name="version" access="read"/>
  </interface>
  <interface name="org.freedesktop.portal.Realtime">
    <method name="MakeThreadRealtimeWithPID">
      <arg type="t" name="process" direction="in"/>
      <arg type="t" name="thread" direction="in"/>
      <arg type="u" name="priority" direction="in"/>
    </method>
    <method name="MakeThreadHighPriorityWithPID">
      <arg type="t" name="process" direction="in"/>
      <arg type="t" name="thread" direction="in"/>
      <arg type="i" name="priority" direction="in"/>
    </method>
    <property type="i" name="MaxRealtimePriority" access="read"/>
    <property type="i" name="MinNiceLevel" access="read"/>
    <property type="x" name="RTTimeUSecMax" access="read"/>
    <property type="u" name="version" access="read"/>
  </interface>
</node>
"
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
$ /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
Copy link

kyechou commented Nov 19, 2022

According to #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.

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 #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 #2978 (comment).

Edit: Attach the working screenshot with the downgraded xdg-desktop-portal 1.14.6
Edit 2: Reported here emersion/xdg-desktop-portal-wlr#246

Screenshot

2022-11-18_21-08

@Phundrak
Copy link

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
Copy link
Author

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/[email protected]/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
Copy link

blurgyy commented Nov 24, 2022

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
Copy link

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
Copy link
Member

@adamant-pwn which versions?

@erikdubois
Copy link

erikdubois commented Dec 4, 2022

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
Copy link
Member

mmahmoudian commented Dec 5, 2022

@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
Copy link

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
Copy link

Hex5DA commented Dec 17, 2022

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

@kyechou
Copy link

kyechou commented Dec 17, 2022

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

@mmahmoudian
Copy link
Member

mmahmoudian commented Dec 18, 2022

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
Copy link

kyechou commented Dec 18, 2022

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: #3018

@ghost
Copy link

ghost commented Dec 28, 2022

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

@nothankyouzzz
Copy link

nothankyouzzz commented Dec 30, 2022

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
Copy link

erikdubois commented Jan 6, 2023

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.
#2978 (comment)

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
Copy link

DexterHaxxor commented Feb 13, 2023

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
Copy link
Member

@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

@Its-Haze
Copy link

All i am getting is this:

Installed:
  flameshot-12.1.0-4.fc39.x86_64                        qtlockedfile-qt5-2.4-39.20150629git5a07df5.fc39.x86_64                        qtsingleapplication-qt5-2.6.1-46.fc39.x86_64                       

Complete!

$flameshot gui                                                                                                                                                     ✔  11s   11:06:49 AM  

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: error: Unable to capture screen
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
flameshot: info: Screenshot aborted.

Im on Fedora.
And using hyprland-git-0.40.0^8.git57e76f9-1.fc39.x86_64 with flameshot-12.1.0-4.fc39.x86_64

@acheong08
Copy link

@Its-Haze Seems like the patch hasn't landed in a release yet.
@mmahmoudian is there a reason a release hasn't been made in such a long time despite numerous improvements and fixes since?

@mmahmoudian
Copy link
Member

@acheong08

@mmahmoudian is there a reason a release hasn't been made in such a long time despite numerous improvements and fixes since?

Yes: time

Any help is more than welcome. Reading the PRs, improving documentations, answering users' issues, helping triage the issues, ...

You can use the nightly build if you want to get those improvements quickly as described on our website:

https://flameshot.org/docs/installation/development-build/

Also AUR (flameshot-git) is always following the HEAD and is managed by us.

@Its-Haze
Copy link

@acheong08

@mmahmoudian is there a reason a release hasn't been made in such a long time despite numerous improvements and fixes since?

Yes: time

Any help is more than welcome. Reading the PRs, improving documentations, answering users' issues, helping triage the issues, ...

You can use the nightly build if you want to get those improvements quickly as described on our website:

https://flameshot.org/docs/installation/development-build/

Also AUR (flameshot-git) is always following the HEAD and is managed by us.

The problem is that fedora has a newer version in their repository, than this "nightly build"
And there is no nightl build available for fc39..

Do i have to build it from source then?

@mmahmoudian
Copy link
Member

The problem is that fedora has a newer version in their repository, than this "nightly build"

How can they have something newer than our latest builds?! What version is there?

Do i have to build it from source then?

You can always build it yourself. It is very straightforward.

@Its-Haze
Copy link

Its-Haze commented Jun 12, 2024

Built flameshot from source, from the head of master. And it did not crash flameshot right away. But taking screenshots made all my screens turn black, so nothing was able to be screenshotted.

@Its-Haze
Copy link

Dnf on Fedora 39 can install flameshot-12.1.0-4.fc39

But the nightly build rpm package was flameshot-12.1.0-1.fc36

Might not be a difference in version. Not sure what differs between 1 and 4 here

@mmahmoudian
Copy link
Member

@Its-Haze

The problem is that fedora has a newer version in their repository, than this "nightly build"

I just checked, Fedora 36 to 40 have v12.1.0:

https://repology.org/project/flameshot/versions

Dnf on Fedora 39 can install flameshot-12.1.0-4.fc39
But the nightly build rpm package was flameshot-12.1.0-1.fc36
Might not be a difference in version. Not sure what differs between 1 and 4 here

That 4 is their internal build version. has nothing to do with Flameshot. Anything after - is irrelevant to our versioning system.

Built flameshot from source, from the head of master. And it did not crash flameshot right away. But taking screenshots made all my screens turn black, so nothing was able to be screenshotted.

Which Desktop Environment or Window Manager are you using?

@mmahmoudian
Copy link
Member

@Its-Haze
Copy link

Im using hyprland. Not gnome

@Its-Haze
Copy link

This is the error i'm getting when running ./flameshot gui after building it from source on Fedora, Hyprland.

flameshot: warning: If the USE_WAYLAND_GRIM option is not activated, the dbus protocol will be used. It should be noted that using the dbus protocol under wayland is not recommended. It is recommended to recompile with the USE_WAYLAND_GRIM flag to activate the grim-based general wayland screenshot adapter
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

The thing that happens is that my all 3 monitors turn black. my waybar is still visible on screen though, so not everything is gone. but mainly my screens. the flameshot gui opens but i cant see what i am going to screenshot, all i see is my mouse moving and i am able to use the differnt keyboard shortcuts to switch

@acheong08
Copy link

Try with cmake -S . -B build -DUSE_WAYLAND_GRIM=true && cmake --build build

For reference, I'm on Hyprland (bf75723f2742973d4820f3f5378dff8c99333660) and it works without that option.

@Its-Haze
Copy link

Try with cmake -S . -B build -DUSE_WAYLAND_GRIM=true && cmake --build build

For reference, I'm on Hyprland (bf75723f2742973d4820f3f5378dff8c99333660) and it works without that option.

will try, building now.

@Its-Haze
Copy link

Try with cmake -S . -B build -DUSE_WAYLAND_GRIM=true && cmake --build build

For reference, I'm on Hyprland (bf75723f2742973d4820f3f5378dff8c99333660) and it works without that option.

Still the same issue, my screens all turn black and the flameshot gui is not visible.

./flameshot gui

flameshot: warning: grim's screenshot component is implemented based on wlroots, it may not be used in GNOME or similar desktop environments
QLayout: Attempting to add QLayout "" to SidePanelWidget "", which already has a layout
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()

@acheong08
Copy link

acheong08 commented Jun 12, 2024

Does grim work? This doesn't seem like a flameshot issue. Might want to update Hyprland and make sure portals are alive.

@Its-Haze
Copy link

I am currently using grimblast, and swappy.

grimblast --freeze copysave area /tmp/screenshot.png && swappy -f /tmp/screenshot.png
rm /tmp/screenshot.png

And it works flawlessly. So i might just stick with it, but i would prefer to use flameshot.

@Its-Haze
Copy link

Its-Haze commented Jun 12, 2024

I found the issue. It was my windowrules for hyprland that messed things up with flameshot.

in .config/hypr/userprefs.conf

I needed to delete/comment out these rows, to make my screens not black out.

windowrulev2=noanim,class:^(flameshot)$
windowrulev2=float,class:^(flameshot)$
windowrulev2=fakefullscreen,class:^(flameshot)$
windowrulev2=monitor 0,class:^(flameshot)$

windowrulev2=move 0 -195,class:^(flameshot)$

Putting this here for people that might have similar rules and end up in the same situation.

@svenstaro
Copy link

Shouldn't this issue perhaps be closed? Flameshot now officially supports Wayland in various forms. Probably wayland problems shouldn't all be grouped under this single issue. It might be more helpful to have other more specific issues for specific problems with Wayland.

@jack9603301
Copy link
Contributor

jack9603301 commented Jul 6, 2024 via email

@suryanarayanan035
Copy link

I have two monitors, left is 1920x1080, right is 2560x1440.

These rules work for me in Hyprland

monitor=eDP-1, preferred, 0x0, 1
monitor=DP-1, preferred, 1920x0, 1

windowrule=fakefullscreen, flameshot
windowrule=float,flameshot
windowrule=monitor 0,flameshot
windowrule=move 0 0,flameshot
windowrule=workspace 0,flameshot
windowrule=stayfocused,flameshot

bind = CTRL+$ALT, A, exec, QT_QPA_PLATFORM=xcb flameshot gui -r | wl-copy

I can successfully use flameshot anywhere i want, just like:

left monitor:

图片

right monitor:

图片

both:

flameshot

I hope my configs is helpful...

This is the one that really worked for me. I use Arch Linux and Hyprland.

@anonymous-user
Copy link

Doesn't the QT_QPA_PLATFORM=xcb mean you are running flameshot in xwayland mode?

@jack9603301
Copy link
Contributor

jack9603301 commented Jul 21, 2024 via email

@SamuelGogarty
Copy link

I have two monitors, left is 1920x1080, right is 2560x1440.
These rules work for me in Hyprland

monitor=eDP-1, preferred, 0x0, 1
monitor=DP-1, preferred, 1920x0, 1

windowrule=fakefullscreen, flameshot
windowrule=float,flameshot
windowrule=monitor 0,flameshot
windowrule=move 0 0,flameshot
windowrule=workspace 0,flameshot
windowrule=stayfocused,flameshot

bind = CTRL+$ALT, A, exec, QT_QPA_PLATFORM=xcb flameshot gui -r | wl-copy

I can successfully use flameshot anywhere i want, just like:
left monitor:
图片
right monitor:
图片
both:
flameshot
I hope my configs is helpful...

This is the one that really worked for me. I use Arch Linux and Hyprland.

fakefullscreen is no longer valid, what should we use in place now?

@Andy3153
Copy link

Andy3153 commented Aug 6, 2024

fakefullscreen is no longer valid, what should we use in place now?

Right from the announcements channel of the Hyprland Discord server, right from Vaxry himself: forgot to mention, fakefullscreen is gone in favor of the new fullscreenstate dispatcher.

Check out the Hyprland Wiki for these things.

@SamuelGogarty
Copy link

SamuelGogarty commented Aug 12, 2024

fakefullscreen is no longer valid, what should we use in place now?

Right from the announcements channel of the Hyprland Discord server, right from Vaxry himself: forgot to mention, fakefullscreen is gone in favor of the new fullscreenstate dispatcher.

Check out the Hyprland Wiki for these things.

should this be used in a different fashion? I am not in the discord.

#flameshot
windowrule=fullscreenstate, flameshot
windowrule=float,flameshot
windowrule=monitor 1,flameshot
windowrule=move 0 0,flameshot
windowrule=workspace 0,flameshot
windowrule=stayfocused,flameshot

With these rules, flameshot still opens on the wrong screen, and displays the wrong window on the wrong screen, doesn't pan across all monitors, etc.

@alba4k
Copy link

alba4k commented Aug 12, 2024

@SamuelGogarty consider removing the workspace 0 windowrule and replace monitor 1 with the minitor name or port (e.g. DP-1)

also, maybe add something like

windowrule = size 3840 1200, flameshot

to make sure the window spans across everything (obv 3840 and 1200 may be different for your setup. if in doubt just throw two 10000 in there)

you might also want to use windowrulev2

windowrulev2 = RULE, class:(flameshot), title:(flameshot)

to make sure other flameshot windows (like the configuration) remain unaffected

unrelated, but in my setup I am also using these rules

  • rounding 0
  • noborder

@twist250
Copy link

@alba4k can you share your full window rules

@alba4k
Copy link

alba4k commented Aug 12, 2024


# Flameshot
windowrulev2 = suppressevent fullscreen, class:(flameshot), title:(flameshot)
windowrulev2 = rounding 0, class:(flameshot), title:(flameshot)
windowrulev2 = noborder, class:(flameshot), title:(flameshot)
windowrulev2 = monitor DP-5, class:(flameshot), title:(flameshot)
windowrulev2 = monitor DP-6, class:(flameshot), title:(flameshot)
windowrulev2 = float, class:(flameshot), title:(flameshot)
windowrulev2 = fullscreenstate, class:(flameshot), title:(flameshot)
windowrulev2 = move 0 0, class:(flameshot), title:(flameshot)
windowrulev2 = stayfocused, class:(flameshot), title:(flameshot)
windowrulev2 = size 3840 1200, class:(flameshot), title:(flameshot)
windowrulev2 = float, class:(flameshot), title:(Upload image)
windowrulev2 = float, class:(flameshot), title:(Configuration)
windowrulev2 = float, class:(flameshot), title:(Capture Launcher)
windowrulev2 = float, class:(flameshot), title:(Save screenshot)

@SamuelGogarty
Copy link


# Flameshot
windowrulev2 = suppressevent fullscreen, class:(flameshot), title:(flameshot)
windowrulev2 = rounding 0, class:(flameshot), title:(flameshot)
windowrulev2 = noborder, class:(flameshot), title:(flameshot)
windowrulev2 = monitor DP-5, class:(flameshot), title:(flameshot)
windowrulev2 = monitor DP-6, class:(flameshot), title:(flameshot)
windowrulev2 = float, class:(flameshot), title:(flameshot)
windowrulev2 = fullscreenstate, class:(flameshot), title:(flameshot)
windowrulev2 = move 0 0, class:(flameshot), title:(flameshot)
windowrulev2 = stayfocused, class:(flameshot), title:(flameshot)
windowrulev2 = size 3840 1200, class:(flameshot), title:(flameshot)
windowrulev2 = float, class:(flameshot), title:(Upload image)
windowrulev2 = float, class:(flameshot), title:(Configuration)
windowrulev2 = float, class:(flameshot), title:(Capture Launcher)
windowrulev2 = float, class:(flameshot), title:(Save screenshot)

these dont seem to work for me either, perhaps im not understanding the correct monitor configuration for this.
Below is my monitor configuration:

❯ hyprctl monitors
Monitor HDMI-A-1 (ID 0):
	[email protected] at 7808x590
	description: BNQ BenQ GW2780 C9J0075901Q
	make: BNQ
	model: BenQ GW2780
	serial: C9J0075901Q
	active workspace: 1 (1)
	special workspace: 0 ()
	reserved: 0 39 0 0
	scale: 1.00
	transform: 1
	focused: no
	dpmsStatus: 1
	vrr: 0
	activelyTearing: false
	disabled: false
	currentFormat: A XRGB8888 H XRGB8888
	availableModes: [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

Monitor DP-2 (ID 1):
	[email protected] at 4808x590
	description: Samsung Electric Company S22F350 H4ZH901055
	make: Samsung Electric Company
	model: S22F350
	serial: H4ZH901055
	active workspace: 2 (2)
	special workspace: 0 ()
	reserved: 0 39 0 0
	scale: 1.00
	transform: 1
	focused: no
	dpmsStatus: 1
	vrr: 0
	activelyTearing: false
	disabled: false
	currentFormat: A XRGB8888 H XRGB8888
	availableModes: [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

Monitor DP-3 (ID 2):
	[email protected] at 5888x1080
	description: Acer Technologies XV271 Z 10502214A4200
	make: Acer Technologies
	model: XV271 Z
	serial: 10502214A4200
	active workspace: 3 (3)
	special workspace: 0 ()
	reserved: 0 39 0 0
	scale: 1.00
	transform: 0
	focused: yes
	dpmsStatus: 1
	vrr: 0
	activelyTearing: false
	disabled: false
	currentFormat: A XRGB8888 H XRGB8888
	availableModes: [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unconfirmed Bug The bug is not confirmed by anyone else. Wayland Wayland specific issues
Projects
None yet
Development

No branches or pull requests