On Arch Linux an index.theme file can be placed under /usr/share/icons/default/ which declares a simple Inherits line for configuring what the default cursor theme is. See https://wiki.archlinux.org/index.php/Cursor_themes
I'm trying to learn how to safely make a similar modification / configuration / derivation with Nix, so that I can experiment with cursor themes that behave consistently across the login manager and other applications.
So far I've used lxappearance to quickly toggle between themes I've installed with environment.systemPackages and then created symlinks from /run/current-system/sw/share/icons/Breeze (for example) to my ~/.icons directory.
This is a local solution that only works post login and feels very brittle.
You might already know this, but for an individual user you can place the index.theme
file at ~/.icons/default/index.theme
.
Yeah that's what I have now but it doesn't work for lightdm :confused: Also it just doesn't feel right making symlinks from the "Global" (environment.systemPackages) to that ~/.icons directory.
I found this on the irc logs, but it's incomplete. https://botbot.me/freenode/nixos/2016-12-23/?msg=78370282&page=4 it doesn't show the rest of whatever derivation I suppose inf-rec ended up building? In anycase now I'm stuck trying to learn how to make a derivation just for the purpose of adding a simple file to a read only directory? :man_shrugging: life.
Looking here: https://nixos.org/nixos/options.html#lightdm
I think you can configure lightdm to use the Breeze theme by:
{
services.xserver.displayManager.lightdm.greeters.gtk.iconTheme = {
package = pkgs.gnome-breeze;
name = "Breeze-gtk";
};
}
or maybe using services.xserver.displayManager.lightdm.greeters.gtk.theme.name
/ services.xserver.displayManager.lightdm.greeters.gtk.theme.package
@grahamc Hey so I tried that but it just makes all the Icons like the face and the icons for buttons and stuff disappear or use their defaults or whatever.
Neither option seems to affect the Mouse Cursor theme. Any other thoughts would be welcome?
I've also tried looking at KDE code but it gets a bit confusing and I don't know what's relevant or not?
I'm not sure about setting it globally but FWIW the way I deal with avoiding symlinks in ~/.icons is by installing the themes into my user's profile and then adding ~/.nix-profile/share/icons to XCURSOR_PATH
environment variable like so:
export XCURSOR_PATH=~/.icons:~/.nix-profile/share/icons/:$XCURSOR_PATH
and sticking that into my .xsessionrc.
For system-wide installed packages I believe lightdm could be modified to set XCURSOR_PATH
to include those like for example in GDM. That would make those packages / cursors available in users' sessions spawned by lightdm without needing to fiddle with XCURSOR_PATH
directly. There is also a pending pr https://github.com/NixOS/nixpkgs/pull/24005 to do that globally independent of any display manager.
For lightdm specifically I was able to patch its source, package definition and service to allow changing cursor theme in a way similar to how services.xserver.displayManager.lightdm.greeters.gtk.iconTheme
can be customised. It allows changing both the theme as well as cursor size.
That seems a bit heavy handed and I guess would require more maintenance due to needing to verify lightm patch whenever package version is bumped. Any thoughts on that?
@pbogdan
Can you elaborate on this method? I have ~/.nix-profile/share/icons/
on my $XCURSOR_PATH
but if I nix-env -iA nixpgs.breeze-gtk
I still have the new, ugly, 17.03 mouseover hand pointer.
@pbogdan I just saw your comment and I was hoping someone had tried patching the lightdm derivation... the lightdm.greeters.gtk.iconTheme works well for icons and whatnot so I was hoping it could be extended to include the configurations for mouse theme. Didn't seem like it would be that difficult but you're correct about the versioning and I'm still not savvy enough with Nix as a language to know where to look to get on the right path.
And what's sad, is the docs / packages seem to have the answer to just about every other question I've had about NixOS.
But seemingly mouse configuration and fhs user environments / nix-shell are still ambiguous to me.
@srhb I tried installing breeze-gtk
, breeze-icons
and breeze-gnome
and it doesn't look like any of those contain any custom cursors :-(. I could be wrong but it looks like only breeze-qt5
has them but it pulls in a ton of qt / kde dependencies and I'm assuming you are not running a DE like KDE or GNOME. Also - how are you setting the active theme?
@erlandsona you can see my lightdm changes here https://github.com/pbogdan/nixpkgs/commit/dfe9a1522928ea02df36712b953b171a8bbb055f They are applied on top of 17.03 channel so not sure if they would work with unstable or master. With those in place cursor theme in lightdm can be set in same way as theme / icon theme:
services.xserver = {
...
displayManager = {
lightdm = {
enable = true;
greeters = {
gtk = {
enable = true;
cursorTheme = {
package = pkgs.gnome3.defaultIconTheme;
name = "Adwaita";
size = 32;
};
};
};
};
...
};
};
It would need some refining but I guess the changes could be submitted to nixpkgs though still not sure if that's a good idea. But in any case it seems to work for me.
And it seems like a bit of a pain, I'm guessing particularly when not using a full DE like GNOME / KDE. Needed some additional fiddling as well for urxvt :-(.
At the risk of sounding pedantic @pbogdan how do I use your patch?
@erlandsona at the moment the only way I'm aware of would be creating your own nixpkgs fork then cherry picking my commit into your fork. Somehow I can't seem to be able to find documentation on that in the official manuals at the moment - are you familiar with working with your own fork?
@pbogdan Forking projects in git yes... under the context of nix & channels and what not, no 馃槙
@erlandsona sorry for delay, I added some instructions based on how I work with my fork here
Working off of pbogdan's work, I have devised a way to change the cursor globally when using lightdm-gtk-greeter; this was specifically asked on IRC by @ylwghst earlier this evening. Sharing here since I believe it can might help others too while waiting for a more comprehensive method. It might be possible to adapt this to another DM.
In the example, it uses the Paper
theme. It also resizes the cursor to a HUGE one.
{ config, lib, pkgs, ... }:
let
# Not sure if this will work when changed, but this is a good default.
theme = config.services.xserver.displayManager.lightdm.greeters.gtk.iconTheme.package;
icons = config.services.xserver.displayManager.lightdm.greeters.gtk.theme.package;
# This is adapted from `<nixpkgs>/nixos/modules/services/x11/display-managers/lightdm-greeters/gtk.nix`
wrappedGtkGreeter = pkgs.runCommand "lightdm-gtk-greeter"
{ buildInputs = [ pkgs.makeWrapper ]; }
''
# This wrapper ensures that we actually get themes
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
$out/greeter \
--prefix PATH : "${pkgs.glibc.bin}/bin" \
--set GDK_PIXBUF_MODULE_FILE "${pkgs.gdk_pixbuf.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" \
--set GTK_PATH "${theme}:${pkgs.gtk3.out}" \
--set GTK_EXE_PREFIX "${theme}" \
--set GTK_DATA_PREFIX "${theme}" \
--set XDG_DATA_DIRS "${theme}/share:${icons}/share" \
--set XDG_CONFIG_HOME "${theme}/share" \
--set XCURSOR_PATH "/run/current-system/sw/share/icons" \
--set XCURSOR_SIZE "64"
cat - > $out/lightdm-gtk-greeter.desktop << EOF
[Desktop Entry]
Name=LightDM Greeter
Comment=This runs the LightDM Greeter
Exec=$out/greeter
Type=Application
EOF
'';
in
{
environment.pathsToLink = [ "/share" ];
environment.systemPackages = with pkgs; [
paper-icon-theme
# Adds a package defining a default icon/cursor theme.
# Based off of: https://github.com/NixOS/nixpkgs/pull/25974#issuecomment-305997110
(pkgs.callPackage ({ stdenv }: stdenv.mkDerivation {
name = "global-cursor-theme";
unpackPhase = "true";
outputs = [ "out" ];
installPhase = ''
mkdir -p $out/share/icons/default
cat << EOF > $out/share/icons/default/index.theme
[Icon Theme]
Name=Default
Comment=Default Cursor Theme
Inherits=Paper
EOF
'';
}) {})
];
services.xserver.displayManager.lightdm.enable = true;
services.xserver.displayManager.lightdm.greeter.package = wrappedGtkGreeter;
}
Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:
Most helpful comment
Working off of pbogdan's work, I have devised a way to change the cursor globally when using lightdm-gtk-greeter; this was specifically asked on IRC by @ylwghst earlier this evening. Sharing here since I believe it can might help others too while waiting for a more comprehensive method. It might be possible to adapt this to another DM.
In the example, it uses the
Paper
theme. It also resizes the cursor to a HUGE one.