From 6b3a71aadf3e2fa8cfb5d77bf330be9c878e9679 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 12 Feb 2024 07:12:04 +0000 Subject: [PATCH] programs: xdg-desktop-portal: dont show app chooser for apps which are the default association --- hosts/common/programs/xdg-desktop-portal.nix | 21 +++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hosts/common/programs/xdg-desktop-portal.nix b/hosts/common/programs/xdg-desktop-portal.nix index 2631e5e5a..a24d57876 100644 --- a/hosts/common/programs/xdg-desktop-portal.nix +++ b/hosts/common/programs/xdg-desktop-portal.nix @@ -1,9 +1,25 @@ -{ config, lib, ... }: +{ config, lib, pkgs, ... }: let cfg = config.sane.programs.xdg-desktop-portal; in { sane.programs.xdg-desktop-portal = { + packageUnwrapped = pkgs.xdg-desktop-portal.overrideAttrs (upstream: { + postPatch = (upstream.postPatch or "") + '' + # wherever we have a default mime association, don't prompt the user to choose an app. + # tracking issues about exposing this formally: + # - + # - + # - + # + # the alternative to patching is to instead manually populate ~/.local/share/flatpak/db + # according to this format (binary): + # - + substituteInPlace --replace-fail src/open-uri.c \ + '#define DEFAULT_THRESHOLD 3' '#define DEFAULT_THRESHOLD 0' + ''; + }); + services.xdg-desktop-portal = { description = "Portal service"; wantedBy = [ "graphical-session.target" ]; @@ -17,6 +33,9 @@ in # xdg-desktop-portal expects to act as a strict frontend and manage xdg-desktop-portal-{gtk,wlr,etc} itself, # which means it needs to know how which endpoints each backend provides and how to launch it, # encoded in /share/xdg-desktop-portal/portals: + # + # tracking issue for having xdg-desktop-portal locate portals via more standard directories, obviating this var: + # - environment.XDG_DESKTOP_PORTAL_DIR = "/etc/profiles/per-user/%u/share/xdg-desktop-portal/portals"; }; };