aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/xdg/default.nix
blob: 5edaf032a4dddb5353127c3b45d4eb122c8cc3c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# xdg - XDG Desktop Portal configuration
{
  config,
  lib,
  pkgs,
  ...
}:
let
  # Hyprland ships its own portal for screensharing/screencasting
  portalPkgs =
    with pkgs;
    [
      xdg-desktop-portal-termfilechooser
    ]
    ++ lib.optionals config.desktop.hyprland.enable [
      xdg-desktop-portal-hyprland
    ]
    ++ lib.optionals (!config.desktop.hyprland.enable) [
      xdg-desktop-portal-gtk
    ];

  defaultPortal = if config.desktop.hyprland.enable then "hyprland" else "gtk";
in
{
  config = lib.mkIf config.desktop.enable {
    xdg.portal = {
      enable = true;
      extraPortals = portalPkgs;
      config.common = {
        "org.freedesktop.impl.portal.FileChooser" = [ "termfilechooser" ];
        default = [ defaultPortal ];
      };
      xdgOpenUsePortal = true;
    };

    home.sessionVariables = {
      GTK_USE_PORTAL = "1";
      TERMCMD = lib.mkIf config.terminal.kitty.enable "${lib.getExe config.terminal.kitty.package} --class file-explorer --title 'Yazi'";
    };
  };
}