NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.46k stars 12.95k forks source link

nwg-launchers: no icons shown #152761

Open asbachb opened 2 years ago

asbachb commented 2 years ago

Describe the bug

A clear and concise description of what the bug is.

Steps To Reproduce

Window Manager: sway

configuration.nix:

  [...]
  programs.sway.enable = true;
  programs.sway.extraPackages = with pkgs; [
    [...]
    gnome3.adwaita-icon-theme
    nwg-launchers
  ];
  programs.sway.wrapperFeatures.gtk = true;

Expected behavior

Show icons.

Screenshots

20211230_18h37m57s_grim

Notify maintainers

@bbigras @Artturin

Metadata

 asbachb@nixos-t14s  ~  nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.11, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.5.1`
 - channels(asbachb): `""`
 - channels(root): `"nixos-22.05pre341453.ac169ec6371, nixos-hardware"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Additional context

asbachb@nixos-t14s  ~  nwggrid
INFO: wm: sway
INFO: Locale: en
INFO: Using css file '"/home/asbachb/.config/nwg-launchers/nwggrid/style.css"'
ERROR: Failed to load icon 'vlc': Icon 'vlc' not present in theme Adwaita
ERROR: Failed to load icon 'vlc': Failed to open file “/usr/share/pixmaps/vlc”: No such file or directory
falling back to placeholder
ERROR: Failed to load icon 'org.gnome.Evince': Icon 'org.gnome.Evince' not present in theme Adwaita
ERROR: Failed to load icon 'org.gnome.Evince': Failed to open file “/usr/share/pixmaps/org.gnome.Evince”: No such file or directory
falling back to placeholder
ERROR: Failed to load icon 'firefox': Icon 'firefox' not present in theme Adwaita
ERROR: Failed to load icon 'firefox': Failed to open file “/usr/share/pixmaps/firefox”: No such file or directory
falling back to placeholder
ERROR: Failed to load icon 'gparted': Icon 'gparted' not present in theme Adwaita
ERROR: Failed to load icon 'gparted': Failed to open file “/usr/share/pixmaps/gparted”: No such file or directory

Icon Loading in nwg_launcher: https://github.com/nwg-piotr/nwg-launchers/blob/4dde40e2a0d82ae87a262e0c2babd22e309d28bf/common/nwg_classes.cc#L243-L263

Artturin commented 2 years ago

works for me with the papirus theme installed with home-manager snippet from strace

newfstatat(AT_FDCWD, "/home/artturin/.nix-profile/share/applications/firefox.desktop", {st_mode=S_IFREG|0555, st_size=302, ...}, 0) = 0
openat(AT_FDCWD, "/home/artturin/.nix-profile/share/applications/firefox.desktop", O_RDONLY) = 12
read(12, "[Desktop Entry]\nCategories=Netwo"..., 8191) = 302
read(12, "", 8191)                      = 0
openat(AT_FDCWD, "/home/artturin/.nix-profile/share/icons/Papirus/96x96/apps/firefox.svg", O_RDONLY) = 13
asbachb commented 2 years ago

@Artturin thanks for having a look into this. With home manager the paths seems to be a little bit different:

openat(AT_FDCWD, "/run/current-system/sw/share/applications/spotify.desktop", O_RDONLY) = 13
read(13, "[Desktop Entry]\nType=Application"..., 8191) = 238
read(13, "", 8191)                      = 0
write(2, "ERROR: ", 7ERROR: )                  = 7
write(2, "Failed to load icon '", 21Failed to load icon ')   = 21
write(2, "spotify-client", 14spotify-client)          = 14
write(2, "': ", 3': )                      = 3
write(2, "Icon 'spotify-client' not presen"..., 50Icon 'spotify-client' not present in theme Adwaita) = 50
write(2, "\n", 1
)                       = 1
openat(AT_FDCWD, "/usr/share/pixmaps/spotify-client", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "ERROR: ", 7ERROR: )                  = 7
write(2, "Failed to load icon '", 21Failed to load icon ')   = 21
write(2, "spotify-client", 14spotify-client)          = 14
write(2, "': ", 3': )                      = 3
write(2, "Failed to open file \342\200\234/usr/shar"..., 86Failed to open file “/usr/share/pixmaps/spotify-client”: No such file or directory) = 86
jtojnar commented 2 years ago

As mentioned on Matrix, the primary issue is that the package lacks librsvg gdk-pixbuf loader.

asbachb commented 2 years ago

@jtojnar I guess we already figured out last time that it does not fix the issue.

jtojnar commented 2 years ago

Might not be a sufficient condition but definitely is a necessary one.

librephoenix commented 4 weeks ago

Made a discovery when analyzing environment variables, since most icons appeared for me when running nwggrid from waybar, whereas elsewhere (from shell or hyprland keybind), many of the icons wouldn't show.

Adding on to the librsvg discussion mentioned earlier in this thread, the (probably incomplete) workaround for this, is running the command with GDK_PIXBUF_MODULE_FILE set to the proper librsvg loaders.cache file. This fixed (most of) this issue for me (on nixos-unstable branch). Here's my config snippet if it helps anyone:

home.packages = with pkgs; [
    nwggrid
    (pkgs.writeScriptBin "nwggrid-wrapper" ''
      #!/bin/sh
      GDK_PIXBUF_MODULE_FILE=${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache nwggrid
    '')
];

Then, just call nwggrid-wrapper instead of nwggrid

*If any of the version numbers change, the above config snippet might not be plug and play.