How to switch to a different xdg-desktop-portal?

In my machine I, have multiple xdg-desktop-portal

$ ls -la /usr/share/xdg-desktop-portal/portals
.rw-r--r-- 100 root 23 Mar 14:48 gnome-keyring.portal
.rw-r--r--  99 root 20 Mar 02:25 gnome-shell.portal
.rw-r--r-- 548 root 18 Oct  2022 gnome.portal
.rw-r--r-- 495 root 29 Nov  2022 gtk.portal

What is the command to switch to a different xdg-desktop-portal?

Asked By: Ahmad Ismail

||

The xdg-desktop-portal is an interface that allows applications to communicate with the desktop environment, it is not something that can be switched between different implementations using an environment variable.

An XDG Desktop Portal (later called XDP) is a program that lets other applications communicate swiftly with the compositor through D-Bus. It’s used for stuff like e.g. opening file pickers, screen sharing.

The different portal implementations you see in the /usr/share/xdg-desktop-portal/portals directory are different portal backends provided by different desktop environments. Each portal backend serves as a bridge between the application and the corresponding desktop environment.

To use a specific xdg-desktop-portal implementation, you would typically need to use a desktop environment that provides that implementation. The desktop environment you are currently using determines which portal backend is used.

If you have multiple desktop environments installed on your machine, you can switch between them by logging out and choosing a different desktop environment at the login screen. Each desktop environment will come with its own default xdg-desktop-portal implementation.

Answered By: Z0OM

While the accepted answer is true, it didn’t provide an answer as to the lower-level mechanisms that select one back-end vs the other or to allow someone to have low-level control. There are two options here.

First, for my system at least, the backend is selected by ~/.config/system/user/xdg-desktop-portal.service.d/override.conf where the following lines let you select an alternate backend:

[Service]
Environment="XDG_CURRENT_DESKTOP=xapp"

As the OP identified, possible values of XDG_CURRENT_DESKTOP can be found as .portal files in /usr/share/xdg-desktop-portal/portals.

However, this is not the only way. portals.conf(5) can be used to select an alternate backend (possibly even per-application backends) using the syntax/example shown in the man page. It would usually be located in $HOME/.config/portals.conf but there are many other options.

Answered By: Seth Robertson
Categories: Answers Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.