Can't start xdg-desktop-portal(-hyprland) automatically

Hyprland version
Hyprland 0.50.1 built from branch  at commit 4e242d086e20b32951fdc0ebcbfb4d41b5be8dcc  ([gha] Nix: update inputs).
Date: Sat Jul 19 21:37:06 2025
Tag: v0.50.1, commits: 6291
built against:
 aquamarine 0.9.2
 hyprlang 0.6.3
 hyprutils 0.8.1
 hyprcursor 0.1.12
 hyprgraphics 0.1.5


no flags were set

Describe your issue / feature…

I’m trying to make xdg-desktop-portal(-hyprland) automatically starting on boot.
Firstly I restarted my PC to check if it was running automatically. Answer is no (xdg-desktop-portal is running but not xdg-desktop-portal-hyprland)
I used the nuclear option from the hyprland documentation, it wasn’t working too.
After iteration and iteration trying to make it working, I got this script:

#!/bin/sh
sleep 1
killall xdg-desktop-portal-hyprland
killall xdg-desktop-portal-gtk
killall xdg-desktop-portal
sleep 1
systemctl --user start xdg-desktop-portal-hyprland
sleep 2
/usr/lib/xdg-desktop-portal &
hyprctl notify 1 5000 "rgb(1effa3)" "XDG desktop portal started."

But it’s still not working, and when I start it manually, sometimes it works on the first time, sometimes it wouldn’t work at all.

How am I supposed to start this service the correct way?

why not just enable the service?

Also, for verifying it works, try screen recording in OBS via pipewire.

I can’t enable that service.

$ systemctl --user enable xdg-desktop-portal-hyprland
The unit files have no installation config (WantedBy=, RequiredBy=, UpheldBy=,
Also=, or Alias= settings in the [Install] section, and DefaultInstance= for
template units). This means they are not meant to be enabled or disabled using systemctl.
 
Possible reasons for having these kinds of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/, .requires/, or .upholds/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

Here is the content of the .service file:

[Unit]
Description=Portal service (Hyprland implementation)
PartOf=graphical-session.target
After=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY

[Service]
Type=dbus
BusName=org.freedesktop.impl.portal.desktop.hyprland
ExecStart=/usr/lib/xdg-desktop-portal-hyprland
Restart=on-failure
Slice=session.slice

As I understand it, it is normal for xdg-desktop-portal to not be started on boot. It is also not intended to be started manually. It should instead be started automatically by D-Bus once you do something that requires it (e.g. screenshare). Does that not work for you?

1 Like

Ah, right yeah. That’s true, I always forget about that. When you launch it manually (not via sysd) then it always runs.

Nope, it doesn’t starts automatically. I tried in OBS and Legcord, both are not working, I have to start xdg-desktop-portal manually.
Have I any way to debug/figure out why it’s not working?

Both qt6-wayland and qt5-wayland are installed.
My XDG env seems good:

$ echo $XDG_CURRENT_DESKTOP
Hyprland
$ echo $XDG_SESSION_TYPE
wayland
$ echo $XDG_SESSION_DESKTOP
Hyprland

And the service starts correctly (it’s started because I manually started the service earlier, but when I boot my system, it’s inactive)

$ systemctl --user status xdg-desktop-portal-hyprland               
● xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-hyprland.service; static)
     Active: active (running) since Sun 2025-08-03 22:33:28 CEST; 3min 27s ago
 Invocation: cc501d4515db4371b843486b676eab3b
   Main PID: 216072 (xdg-desktop-por)
      Tasks: 4 (limit: 76945)
     Memory: 1.4M (peak: 2.2M)
        CPU: 19ms
     CGroup: /user.slice/user-1000.slice/[email protected]/session.slice/xdg-desktop-portal-hyprland.service
             └─216072 /usr/lib/xdg-desktop-portal-hyprland

Aug 03 22:33:28 Piripe-PC systemd[742]: Starting Portal service (Hyprland implementation)...
Aug 03 22:33:28 Piripe-PC systemd[742]: Started Portal service (Hyprland implementation).

My first intuition would be to monitor D-Bus while you are trying to start a screen recording, and try to see why the portal is not started. The Arch wiki lists some debugging tools for D-Bus here. From a quick look (and a very quick test), bustle seems quite promising, since it supports recording D-Bus events. Though I don’t have any personal experiences with D-Bus (beyond of course passively using it).

Okay, after some investigations with Bustle and btop, I seen that D-Bus actually starts xdg-desktop-portal, but returns an error everytime (unless I start it manually). Then I looked into btop to see if xdg-desktop-portal is correctly started and was surprised to see that D-BUS starts xdg-desktop-portal-gtk instead of xdg-desktop-portal-hyprland.
I uninstalled xdg-desktop-portal-gtk before figuring out that it’s the program that manages the theme for GTK apps (my eyes are burning in front of dolphin in light mode)
And I still get the errors. After connecting some of my brain cells, I read the error:

("No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop",)

but I can actually see when starting xdg-desktop-portal -v:

XDP: Using hyprland.portal for org.freedesktop.impl.portal.ScreenCast (config)
XDP: providing portal org.freedesktop.portal.ScreenCast

WHO IS LYING!?

(btw I reinstalled xdg-desktop-portal-gtk)

what I run
systemctl status --user xdg-desktop-portal-hyprland
I get

● xdg-desktop-portal-hyprland.service - Portal service (Hyprland implementation)
     Loaded: loaded (/usr/lib/systemd/user/xdg-desktop-portal-hyprland.service; static)
     Active: active (running) since Sun 2025-08-03 18:06:46 PDT; 9s ago
 Invocation: d7b5a774808d403b979d8412009c97f1
   Main PID: 812 (xdg-desktop-por)
      Tasks: 6 (limit: 18687)
     Memory: 9.2M (peak: 9.8M)
        CPU: 51ms
     CGroup: /user.slice/user-1000.slice/[email protected]/session.slice/xdg-desktop-portal-hyprland.service
             └─812 /usr/lib/xdg-desktop-portal-hyprland

Aug 03 18:06:46 portable systemd[589]: Starting Portal service (Hyprland implementation)...
Aug 03 18:06:46 portable systemd[589]: Started Portal service (Hyprland implementation).

All I did was pacman -S xdg-desktop-portal-hyprland with no extra systemctl calls or reboot. It was running prior to reboot and after rebooting it started automatically which is what is showing. I’m not sure if something else I have installed is launching it.