Jump to content

Cursor Themes: Difference between revisions

From Official NixOS Wiki
Dafitt (talk | contribs)
Added Troubleshooting for - Gnome apps under hyprland - Flatpaks
DHCP (talk | contribs)
m style fixes
 
(One intermediate revision by one other user not shown)
Line 12: Line 12:


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


Line 81: Line 81:
This already fixes themes for most apps like gnome. But not all (e.g. Obsidian or Logseq).
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">
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>'':
flatpak --user override --filesystem=/nix/store:ro
<syntaxhighlight lang=console>
$ flatpak --user override --filesystem=/nix/store:ro
</syntaxhighlight>OR with the https://github.com/gmodena/nix-flatpak homeManagerModule:<syntaxhighlight lang="nix">
</syntaxhighlight>OR with the https://github.com/gmodena/nix-flatpak homeManagerModule:<syntaxhighlight lang="nix">
services.flatpak = {
services.flatpak = {
Line 94: Line 95:
};
};
</syntaxhighlight>
</syntaxhighlight>
[[Category:Configuration]]

Latest revision as of 14:16, 19 July 2026

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" ];
    };
  };
};