Jump to content

Cursor Themes: Difference between revisions

From NixOS Wiki
AveryKoen (talk | contribs)
mNo edit summary
Dafitt (talk | contribs)
Added Troubleshooting for - Gnome apps under hyprland - Flatpaks
Line 34: Line 34:
         "Fuchsia-Pop";  
         "Fuchsia-Pop";  
</syntaxHighlight>
</syntaxHighlight>
== Troubleshooting ==
=== Cursor themes in Gnome apps under Hyprland are different / not applied ===
Try giving the Gnome apps an extra kick with:<syntaxhighlight lang="nix">
wayland.windowManager.hyprland.settings = {
  exec-once = [
    # Fixes cursor themes in gnome apps under hyprland
    "gsettings set org.gnome.desktop.interface cursor-theme '${config.home.pointerCursor.name}'"
    "gsettings set org.gnome.desktop.interface cursor-size ${toString home.pointerCursor.size}"
  ];
};
</syntaxhighlight>
=== Cursor themes in flatpaks are different / not applied ===
==== Set <code>xdg-desktop-portal-gtk</code> as fallback ====
Most flatpaks need the functions implemented by <code>xdg-desktop-portal-gtk</code> and other desktop portals are not always implementing everything in <code>xdg-desktop-portal-gtk</code> themself. So its a good idea to set<code>xdg-desktop-portal-gtk</code> as a fallback.
This can be achieved in home-manager through <code>xdg.portals.config</code>:<syntaxhighlight lang="nix">
xdg.portal = {
  config = {
    # example with hyprland
    hyprland.preferred = [ "hyprland" "gtk" ];
  };
};
</syntaxhighlight>OR in home-manager through <code>xdg.portals.configPackages</code>:<syntaxhighlight lang="nix">
xdg.portal = {
  # example with hyprland
  configPackages = [ pkgs.hyprland ];
  # has a file with /nix/store/...-hyprland-.../share/xdg-desktop-portal/hyprland-portals.conf
  # 1 │ [preferred]
  # 2 │ default=hyprland;gtk
};
</syntaxhighlight>Keep in mind that with the home-manager module <code>wayland.windowManager.hyprland.enable</code> this is already done. See [./Https://github.com/nix-community/home-manager/blob/22b418c13fb0be43f4bc5c185f323a3237028594/modules/services/window-managers/hyprland.nix#L298 github.com/nix-community/home-manager/blob/master/modules/services/window-managers/hyprland.nix]
==== Make sure <code>xdg-desktop-portal-gtk</code> is running ====
For flatpaks you need to make sure the <code>xdg-desktop-portal-gtk</code> is running in userspace, which is not automatically always the case (espacially on tiling windowManagers). So in home-manager you can set:<syntaxhighlight lang="nix">
xdg.portal = {
  enable = true;
  extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; # Fixes OpenURI and cursor themes in flatpaks
};
</syntaxhighlight>
==== Giving flatpaks permission to ''<code>/nix/store</code>'' ====
This already fixes themes for most apps like gnome. But not all (e.g. Obsidian or Logseq).
And since flatpaks are sandboxed and dont have access to the nix-store you need to give them permission, since the cursors are eventually linked to ''<code>/nix/store/...</code>'':<syntaxhighlight lang="shell">
flatpak --user override --filesystem=/nix/store:ro
</syntaxhighlight>OR with the https://github.com/gmodena/nix-flatpak homeManagerModule:<syntaxhighlight lang="nix">
services.flatpak = {
  enable = true;
  overrides = {
    global = {
      Context.filesystems = [ "/nix/store:ro" ];
    };
  };
};
</syntaxhighlight>

Revision as of 16:08, 13 February 2025

To install the DMZ white cursor theme with add this to your Home Manager config:

home.file.".icons/default".source = "${pkgs.vanilla-dmz}/share/icons/Vanilla-DMZ";

For a more fine-grained configuration, check the option xsession.pointerCursor.

Cursor Theme with Home Manager

Here's an example how you can get a cursor theme from a url and assign it to HM's pointerCursor:

  home.pointerCursor = 
    let 
      getFrom = url: hash: name: {
          gtk.enable = true;
          x11.enable = true;
          name = name;
          size = 48;
          package = 
            pkgs.runCommand "moveUp" {} ''
              mkdir -p $out/share/icons
              ln -s ${pkgs.fetchzip {
                url = url;
                hash = hash;
              }} $out/share/icons/${name}
          '';
        };
    in
      getFrom 
        "https://github.com/ful1e5/fuchsia-cursor/releases/download/v2.0.0/Fuchsia-Pop.tar.gz"
        "sha256-BvVE9qupMjw7JRqFUj1J0a4ys6kc9fOLBPx2bGaapTk="
        "Fuchsia-Pop";

Troubleshooting

Cursor themes in Gnome apps under Hyprland are different / not applied

Try giving the Gnome apps an extra kick with:

wayland.windowManager.hyprland.settings = {
  exec-once = [
    # Fixes cursor themes in gnome apps under hyprland
    "gsettings set org.gnome.desktop.interface cursor-theme '${config.home.pointerCursor.name}'"
    "gsettings set org.gnome.desktop.interface cursor-size ${toString home.pointerCursor.size}"
  ];
};

Cursor themes in flatpaks are different / not applied

Set xdg-desktop-portal-gtk as fallback

Most flatpaks need the functions implemented by xdg-desktop-portal-gtk and other desktop portals are not always implementing everything in xdg-desktop-portal-gtk themself. So its a good idea to setxdg-desktop-portal-gtk as a fallback.

This can be achieved in home-manager through xdg.portals.config:

xdg.portal = {
  config = {
    # example with hyprland
    hyprland.preferred = [ "hyprland" "gtk" ];
  };
};

OR in home-manager through xdg.portals.configPackages:

xdg.portal = {
  # example with hyprland
  configPackages = [ pkgs.hyprland ];
  # has a file with /nix/store/...-hyprland-.../share/xdg-desktop-portal/hyprland-portals.conf
  # 1 │ [preferred]
  # 2 │ default=hyprland;gtk
};

Keep in mind that with the home-manager module wayland.windowManager.hyprland.enable this is already done. See [./Https://github.com/nix-community/home-manager/blob/22b418c13fb0be43f4bc5c185f323a3237028594/modules/services/window-managers/hyprland.nix#L298 github.com/nix-community/home-manager/blob/master/modules/services/window-managers/hyprland.nix]

Make sure xdg-desktop-portal-gtk is running

For flatpaks you need to make sure the xdg-desktop-portal-gtk is running in userspace, which is not automatically always the case (espacially on tiling windowManagers). So in home-manager you can set:

xdg.portal = {
  enable = true;
  extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; # Fixes OpenURI and cursor themes in flatpaks
};

Giving flatpaks permission to /nix/store

This already fixes themes for most apps like gnome. But not all (e.g. Obsidian or Logseq).

And since flatpaks are sandboxed and dont have access to the nix-store you need to give them permission, since the cursors are eventually linked to /nix/store/...:

flatpak --user override --filesystem=/nix/store:ro

OR with the https://github.com/gmodena/nix-flatpak homeManagerModule:

services.flatpak = {
  enable = true;

  overrides = {
    global = {
      Context.filesystems = [ "/nix/store:ro" ];
    };
  };
};