NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.67k stars 13.81k forks source link

Nautilus doesn't know how to open files, unless launched from terminal first #177900

Open Lyndeno opened 2 years ago

Lyndeno commented 2 years ago

Describe the bug

When using Nautilus in sway, this does not happen in Gnome, right clicking a file like a .pdf, then "Open with other application" will show "No applications found for "file.pdf""

This happens for pretty much all files, though when doing this on a .jpg it shows "Imv" and "Signal Desktop" as possible applications to open in.

Launching Nautilus from a terminal works just fine.

Steps To Reproduce

  1. Launch Nautilus with a launcher like Wofi
  2. Try to open a file
  3. See as Nautilus does not know which programs to use to open a file

Expected behavior

Nautilus should know how to open a file.

Screenshots

image

Additional context

Sway is configured with gtk wrapper features enabled.

Notify maintainers

@bobby285271 @hedning @dasj19 @maxeaubrey

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.46, NixOS, 22.05 (Quokka), 22.05.20220614.9ff91ce`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.8.1`
 - channels(root): `"home-manager-22.05.tar.gz, nixos-22.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
maxhille commented 1 year ago

I had the same problem since a while and investigated quite a bit. I expected it has to do with some Gnome/Dbus/Env problem (just because there are tons of those with Sway and NixOS).

I basically rebuilt my sway setup to try to debug this problem and use up to date Nix packages (I did not use programs.sway before). So now I am basically running Sway like suggested in the NixOS repo and Greetd wiki. Note that I have to run Sway from Greetd via dbus-run-session sway although programs.sway with base = true should do this but for me it does not seem to. Maybe @colemickens can enlighten us :-)

Switching to this config fixed the problem for me:

    # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/sway.nix
    programs.sway = {
        enable = true;
        wrapperFeatures = {
            base = true;
            gtk = true;
        };
        extraSessionCommands = ''
            # SDL:
            export SDL_VIDEODRIVER=wayland
            # QT (needs qt5.qtwayland in systemPackages):
            export QT_QPA_PLATFORM=wayland-egl
            export QT_WAYLAND_DISABLE_WINDOWDECORATION="1"
            # Fix for some Java AWT applications (e.g. Android Studio),
            # use this if they aren't displayed properly:
            export _JAVA_AWT_WM_NONREPARENTING=1
        '';
        extraPackages = with pkgs; [ swaylock swayidle foot dmenu mako grim slurp ];
    };

    # minimal greetd: log in spec'd user automatically
    # https://nixos.wiki/wiki/Greetd
    services.greetd = {
        enable = true;
        settings = rec {
            initial_session = {
                command = "dbus-run-session sway";
                user = "mh";
            };
            default_session = initial_session;
        };
    };
abmantis commented 8 months ago

I am having this issue with Hyprland, using wofi to launch nautilus. If it is launched from the terminal, it works fine. I already have this overlay for hyprland, but it still does not work:

    (final: prev:
      {
        hyprland = prev.hyprland.overrideAttrs (old: {
          nativeBuildInputs = old.nativeBuildInputs ++ [ pkgs.wrapGAppsHook ];
        });
      })
pixL404 commented 7 months ago

I am having this issue with Hyprland, using wofi to launch nautilus. If it is launched from the terminal, it works fine. I already have this overlay for hyprland, but it still does not work:

This is exactly my current problem.

This Reddit thread has a similar issue and points to this nixOS discourse.

The error seems, that the calling application doesn't set the PATH or DBus environment properly? At least with Hyprland (as a flake) my hypr.conf starts with the following, which I assume does this:

exec-once = /nix/store/xxx-dbus-1.14.10/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target
abmantis commented 7 months ago

I am having this issue with Hyprland, using wofi to launch nautilus. If it is launched from the terminal, it works fine. I already have this overlay for hyprland, but it still does not work:

This is exactly my current problem.

This Reddit thread has a similar issue and points to this nixOS discourse.

The error seems, that the calling application doesn't set the PATH or DBus environment properly? At least with Hyprland (as a flake) my hypr.conf starts with the following, which I assume does this:

exec-once = /nix/store/xxx-dbus-1.14.10/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target

I forgot to leave an update here, but you are right. For me, this fixed it:

exec-once=dbus-update-activation-environment PATH