Add page: XDG Desktop Portal configuration

Douglas Silva 2024-09-08 20:32:31 -03:00
parent b097e51621
commit 679f768599

@ -0,0 +1,31 @@
Without configuring portals, you may find that many desktop actions such as "open in browser" or "select a file" do not work. Not all distributions ship the necessary configuration files in their Sway package (Arch Linux is one that does it), so we need to know how to do it ourselves.
Make sure you have installed both the `gtk` and `wlr` portal backends.
## Setup the environment
From [xdg-desktop-portal-wlr](https://github.com/emersion/xdg-desktop-portal-wlr/tree/master?tab=readme-ov-file#running):
> Make sure `XDG_CURRENT_DESKTOP` is set. Make sure `WAYLAND_DISPLAY` and `XDG_CURRENT_DESKTOP` are imported into D-Bus. If you're running Sway, this can be added to your config file:
```sh
exec dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway
```
`--systemd` can be omitted if you don't use it.
## Set the portals Sway should use
From `portals.conf(5)`:
> Desktop environments and OS vendors should provide a configuration for their chosen portal backends in `/usr/share/xdg-desktop-portal/DESKTOP-portals.conf`, where DESKTOP is the desktop environment name as it would appear in the `XDG_CURRENT_DESKTOP` environment variable.
If your distribution didn't include it with the Sway package, you'll need to create a `sway-portals.conf` file.
> Users can override those defaults, or provide configuration for an otherwise unsupported desktop environment, by writing a file `~/.config/xdg-desktop-portal/portals.conf`. Users of more than one desktop environment can use desktop-specific filenames such as kde-portals.conf which will only be used in the appropriate desktop environment.
Create `~/.config/xdg-desktop-portal/sway-portals.conf` with the following settings:
```ini
[preferred]
default=gtk
org.freedesktop.impl.portal.Screenshot=wlr
org.freedesktop.impl.portal.ScreenCast=wlr
```
> Similarly, system administrators can provide a default configuration for all users in `/etc/xdg-desktop-portal/DESKTOP-portals.conf` or `/etc/xdg-desktop-portal/portals.conf`.
Restart Sway to apply the changes.