From 679f768599de1b9e247fc612c21b78180e35a14c Mon Sep 17 00:00:00 2001 From: Douglas Silva Date: Sun, 8 Sep 2024 20:32:31 -0300 Subject: [PATCH] Add page: XDG Desktop Portal configuration --- XDG-Desktop-Portal-configuration.md | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 XDG-Desktop-Portal-configuration.md diff --git a/XDG-Desktop-Portal-configuration.md b/XDG-Desktop-Portal-configuration.md new file mode 100644 index 0000000..82532c4 --- /dev/null +++ b/XDG-Desktop-Portal-configuration.md @@ -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. \ No newline at end of file