NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.43k stars 13.64k forks source link

ulauncher does not show installed apps #214668

Open shackra opened 1 year ago

shackra commented 1 year ago

Describe the bug

Ulauncher fails to display installed apps from NixOS

Steps To Reproduce

Install spotify, notion-app-enhance or minecraft-launcher.

Expected behavior

I should be able to invoke Ulauncher and see any of the above apps, it can read .desktop files from the usual locations

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

I use an script to symlink what's on /home/jorge/.nix-profile/share/applications to ~/.local/share/applications, take a look:

#!/usr/bin/env sh

set -e +x

export LOCALSHAREAPPS=~/.local/share/applications
export NIXSHAREAPPS=~/.nix-profile/share/applications

find $LOCALSHAREAPPS -iname 'nix-*.desktop' -delete;

for app in $(ls $NIXSHAREAPPS)
do
    ln -s $NIXSHAREAPPS/$app $LOCALSHAREAPPS/nix-$app;
done

update-desktop-database -v $LOCALSHAREAPPS;

Despite this, ulauncher still fails to show these symlinked apps.

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"
bash: warning: setlocale: LC_ALL: cannot change locale (es_CR.UTF-8)
/nix/store/pj1hnyxhcsw1krmhnbb9rjvqssbzliw8-bash-5.2-p15/bin/bash: warning: setlocale: LC_ALL: cannot change locale (es_CR.UTF-8)
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.7-arch1-1, EndeavourOS, noversion, 2022.09.10`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.2`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
shackra commented 1 year ago

I tried setting my XDG_DATA_DIRS as follows and it somehow broke the startup of my session:

if [ -e "$HOME/.nix-profile/share/" ]; then
    export XDG_DATA_DIRS="$HOME/.nix-profile/share:$XDG_DATA_DIRS"
fi

this, however, works if I export on a terminal and run ulauncher or dmenu.

chrillefkr commented 1 year ago

I experienced the same problem, which was because I was running ulauncher through systemd. Systemd sets PATH environment variable to some standard value for the service, as described here.

My solution was to write a small wrapper script to setup the PATH variable before starting ulauncher, as such:

  systemd.user.services.ulauncher = {
    Unit = {
      Description = "Linux Application Launcher";
      Documentation = [ "https://ulauncher.io/" ];
    };

    Service = {
      Type = "Simple";
      Restart = "Always";
      RestartSec = 1;
      ExecStart = pkgs.writeShellScript "ulauncher-env-wrapper.sh" ''
        export PATH="''${XDG_BIN_HOME}:$HOME/.nix-profile/bin:/etc/profiles/per-user/$USER/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
        export GDK_BACKEND=x11
        exec ${pkgs.ulauncher}/bin/ulauncher --hide-window
      '';
    };

    Install = {
      WantedBy = [ "graphical-session.target" ];
    };
  };