NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.3k stars 13.54k forks source link

Chromium does not show file dialogs under Sway #262286

Open gesperon opened 10 months ago

gesperon commented 10 months ago

Describe the bug

Chromium does not show file dialogs under sway. /run/current-system/sw/share/xdg-desktop-portal/portals/gtk.portal has:


[portal]
DBusName=org.freedesktop.impl.portal.desktop.gtk
Interfaces=org.freedesktop.impl.portal.FileChooser;org.freedesktop.impl.portal.Print;org.freedesktop.impl.portal.Notification;org.freedesktop.impl.portal.Inhibit;org.freedesktop.impl.portal.Access;org.freedesktop.impl.portal.Account;org.freedesktop.impl.portal.Email;org.freedesktop.impl.portal.DynamicLauncher;org.freedesktop.impl.portal.Lockdown;
UseIn=gnome

Steps To Reproduce

Steps to reproduce the behavior:

  1. Have Gnome, Sway and Chromium installed (I am also running gdm and i3).
  2. Login into a Sway session.
  3. Launch Chromium and try to "Save as" an image or page. Or try to upload a file somewhere.
  4. The file dialog won't show up.

Expected behavior

For a file dialog to show up.

Additional context

I temporally fixed this behavior on my local PC forcing UseIn=gnome;sway:

nixpkgs.overlays = [ (self: super: {
  xdg-desktop-portal-gtk = super.xdg-desktop-portal-gtk.overrideAttrs {
    postInstall = ''
      sed -i 's/UseIn=gnome/UseIn=gnome;sway/' $out/share/xdg-desktop-portal/portals/gtk.portal
    '';
  };
} ) ];

but this is really ugly and dirty.

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

> nix-shell -p nix-info --run "nix-info -m"                                                                                                                                                                                                                                4m 39s todo 8
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.7, NixOS, 23.11 (Tapir), 23.11.20231019.8d77279`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.1`
 - channels(root): `"home-manager, nixos, nixpkgs, sops-nix"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

EDIT: running: Chromium Version 118.0.5993.70 (Official Build) (64-bit) from /nix/store/ykq2may73q4gvw6rdbrsngdnw98cwpbg-chromium-118.0.5993.70/bin/chromium (in case someone needs to compare hash).

eclairevoyant commented 10 months ago

are you using ozone wayland?

gesperon commented 10 months ago

@eclairevoyant

Do you mean the steps in https://nixos.wiki/wiki/Chromium ? under "Enabling native Wayland support" ? if so yes. I have trying both the environment variable and passing the arguments to chromium to no avail.

eclairevoyant commented 10 months ago

I would suggest trying without ozone wayland, as it's known to have some issues.

gesperon commented 10 months ago

Good to know. I have it disabled, so with or without it does not make a difference at least for the file dialogs.

puzzlewolf commented 10 months ago

I had the same problem with element-desktop and other apps, also with Gnome installed but not used. https://nixos.wiki/wiki/Sway#Using_NixOS suggests some workarounds for gtk applications. In my case, setting wrapperFeatures.gtk = true seems to be enough.

  programs.sway = {
    enable = true;
    wrapperFeatures.gtk = true;
  };
gesperon commented 10 months ago

wrapperFeatures.gtk = true; does not fix the issue for me. Do you have xdg.portal.extraPortals = [ pkgs.xdg-desktop-portal-gtk ] ; ?

philpax commented 1 month ago

I used your overlays workaround to solve this issue for myself. Thank you for putting it forward!

I can confirm that having wrapperFeatures.gtk = true and extraPortals = [ pkgs.xdg-desktop-portal-gtk ] does not resolve this by default.