2024-02-20 21:16:07 +01:00
---
weight: 5
title: Hyprland Desktop Portal
---
2022-12-03 23:52:10 +01:00
An XDG Desktop Portal (later called XDP) is a program that lets other
applications communicate swiftly with the compositor through D-Bus.
2024-04-21 16:35:48 +02:00
It's used for things like opening file pickers or screen sharing.
2022-12-03 23:52:10 +01:00
2024-02-20 21:16:07 +01:00
On Wayland, it also requires an implementation. For Hyprland, you'd usually use
`xdg-desktop-portal-wlr` (later called XDPW)
2022-12-03 23:52:10 +01:00
2024-02-20 21:16:07 +01:00
Unfortunately, due to various reasons the -wlr portal is inferior to the KDE or
2024-04-21 16:35:48 +02:00
GNOME ones.
2022-12-03 23:52:10 +01:00
2024-02-20 21:16:07 +01:00
In order to bridge the gap, Hyprland has its own fork of XDPW that has more
features, called
[xdg-desktop-portal-hyprland ](https://github.com/hyprwm/xdg-desktop-portal-hyprland ).
2022-12-03 23:52:10 +01:00
(later called XDPH)
2024-02-20 21:16:07 +01:00
{{< callout > }}
You don't **need** XDPH. Hyprland will work with XDPW, but XDPH has more
2024-04-21 16:35:48 +02:00
features, such as window sharing.
2024-02-20 21:16:07 +01:00
XDPH will work on other wlroots-based compositors, although limited to the XDPW
features (other will be disabled).
2022-12-05 02:07:34 +01:00
2024-02-20 21:16:07 +01:00
{{< / callout > }}
2022-12-03 23:52:10 +01:00
## Installing
2024-02-20 21:16:07 +01:00
{{< tabs items = "Arch Linux,Gentoo,Manual" > }}
2022-12-03 23:52:10 +01:00
2022-12-17 23:54:38 +01:00
{{< tab " Arch Linux " > }}
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
```plain
2023-04-11 00:03:21 +02:00
pacman -S xdg-desktop-portal-hyprland
```
2024-02-20 21:16:07 +01:00
2023-04-11 00:03:21 +02:00
or, for -git:
2024-02-20 21:16:07 +01:00
2023-04-11 00:03:21 +02:00
```plain
2022-12-05 02:01:55 +01:00
yay -S xdg-desktop-portal-hyprland-git
```
2023-01-20 16:56:34 +01:00
2022-12-17 23:54:38 +01:00
{{< / tab > }}
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
{{< tab " Gentoo " > }}
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
## Unmask dependencies
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
### /etc/portage/profile/package.unmask
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
```plain
2023-05-02 15:28:02 +02:00
dev-qt/qtbase
dev-qt/qtwayland
dev-qt/qtdeclarative
dev-qt/qtshadertools
2022-12-17 23:54:38 +01:00
```
## Apply necessary useflags
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
### /etc/portage/package.use
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
```plain
dev-qt/qtbase opengl egl eglfs gles2-only
dev-qt/qtdeclarative opengl
sys-apps/xdg-desktop-portal screencast
```
## Unmask dependencies and xdph
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
### /etc/portage/package.accept_keywords
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
```plain
2023-05-05 01:33:12 +02:00
gui-libs/xdg-desktop-portal-hyprland
2023-05-02 15:28:02 +02:00
dev-qt/qtbase
dev-qt/qtwayland
dev-qt/qtdeclarative
dev-qt/qtshadertools
2022-12-17 23:54:38 +01:00
```
2023-05-02 15:28:02 +02:00
btw those are the useflags that I have tested, you could also test others.
2022-12-17 23:54:38 +01:00
## Installation
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
```sh
2023-05-02 15:28:02 +02:00
eselect repository enable guru
emaint sync -r guru
2022-12-17 23:54:38 +01:00
emerge --ask --verbose gui-libs/xdg-desktop-portal-hyprland
```
{{< / tab > }}
2024-02-20 21:16:07 +01:00
2022-12-17 23:54:38 +01:00
{{< tab " Manual " > }}
2024-02-20 21:16:07 +01:00
See
[The Github repo's readme ](https://github.com/hyprwm/xdg-desktop-portal-hyprland ).
2022-12-03 23:52:10 +01:00
2022-12-17 23:54:38 +01:00
{{< / tab > }}
{{< / tabs > }}
2024-02-20 21:16:07 +01:00
{{< callout type = info > }}
XDPH doesn't implement a file picker. For that, I recommend installing
`xdg-desktop-portal-gtk` alongside XDPH.
{{< / callout > }}
2022-12-05 02:01:55 +01:00
## Usage
Should start automatically.
2024-04-21 16:35:48 +02:00
The most basic way of seeing if everything is OK is by trying to screenshare
anything, or by opening OBS and selecting the PipeWire source. If XDPH is running, a Qt menu
2024-02-20 21:16:07 +01:00
will pop up asking you what to share.
2022-12-05 02:01:55 +01:00
2024-04-21 16:35:48 +02:00
If it doesn't, or if, for example, `slurp` gets opened instead, then XDPW is launching. In that case, try
2024-02-20 21:16:07 +01:00
removing XDPW.
2022-12-05 02:01:55 +01:00
2024-02-20 21:16:07 +01:00
XDPH will work on other wlroots compositors, but features available only on
2024-04-21 16:35:48 +02:00
Hyprland will not work (e.g. window sharing).
2022-12-03 23:52:10 +01:00
For a nuclear option, you can use this script and `exec-once` it:
2024-02-20 21:16:07 +01:00
2022-12-03 23:52:10 +01:00
```sh
2024-03-08 00:38:37 +01:00
#!/usr/bin/env bash
2022-12-03 23:52:10 +01:00
sleep 1
2023-06-04 10:47:08 +02:00
killall -e xdg-desktop-portal-hyprland
killall -e xdg-desktop-portal-wlr
2022-12-03 23:52:10 +01:00
killall xdg-desktop-portal
2023-02-08 11:18:09 +01:00
/usr/lib/xdg-desktop-portal-hyprland &
2022-12-03 23:52:10 +01:00
sleep 2
/usr/lib/xdg-desktop-portal &
```
2024-02-20 21:16:07 +01:00
2024-04-21 16:35:48 +02:00
Adjust the paths if they're incorrect.
2023-02-17 00:56:49 +01:00
2023-10-06 15:32:02 +02:00
## Share picker doesn't use the system theme
Try one or both:
2024-02-20 21:16:07 +01:00
2023-10-06 15:32:02 +02:00
```sh
dbus-update-activation-environment --systemd --all
systemctl --user import-environment QT_QPA_PLATFORMTHEME
```
2024-04-21 16:35:48 +02:00
If it works, add it to your config in `exec-once` .
2023-10-06 15:32:02 +02:00
2024-03-08 17:36:34 +01:00
## Using the KDE file picker with XDPH
XDPH does not implement a file picker and uses the GTK one as a fallback by default (see `/usr/share/xdg-desktop-portal/hyprland-portals.conf` ). If you want to use the KDE file picker but let XDPH handle everything else, create a file `~/.config/xdg-desktop-portal/hyprland-portals.conf` with the following content:
```properties
[preferred]
default=hyprland;gtk
org.freedesktop.impl.portal.FileChooser=kde
```
2024-04-21 16:35:48 +02:00
You can read more about this in the [xdg-desktop-portal documentation in the Arch Wiki ](https://wiki.archlinux.org/title/XDG_Desktop_Portal ). Note that some applications like Firefox may require additional configuration to use the KDE file picker.
2024-03-08 17:36:34 +01:00
2023-02-17 00:56:49 +01:00
## Debugging
2024-02-20 21:16:07 +01:00
If you get long app launch times, or screensharing does not work, consult the
logs.
2023-02-17 00:56:49 +01:00
`systemctl --user status xdg-desktop-portal-hyprland`
2024-04-21 16:35:48 +02:00
If you see a crash, it's likely you are missing either `qt6-wayland` or
2024-02-20 21:16:07 +01:00
`qt5-wayland` .