Cursor size in wayland/sway

I’m using wayland/sway and find that my cursor size changes when hovering over different windows. It is smaller on window borders than on most “regular” windows. It is tiny when hoving over a mpv window. Does somebody know the reason for this?

1 Like

Did you ever find a solution? It’s driving me crazy

No, unfortunately not

I managed to find the culprit of my particular issue, I’m not sure if yours is the same:

Other than that I’ve seen a lot of people recommend to set XCUSOR_SIZE=size env variable for XWayland/Flatpak apps to maintain consistency:

Also, using Home Manager allowed me to set the cursor theme for GDK globally (I haven’t tested any QT apps with this though). This way I don’t have to define the cursor theme in gtk.cursorTheme or my .config:

home.pointerCursor = {
  gtk.enable = true;
  package = pkgs.bibata-cursors;
  name = "Bibata-Modern-Ice";
  size = 22;

Hope this helps!
If you find any other workaround to your issue, make sure to update this thread so others can learn :slight_smile:

1 Like

I think we have different issues - if I understood you right, your mouse cursor slightly changed size when moving, even within the same window. What I see is that the cursor size can be way different depending on the window it’s hovering.

Regarding my issue:

As far as I understand, in wayland every application is responsible for drawing the cursor hovering over its windows, so I would have to teach each application how to use the correct size.

I found various places indicating that some applications read the XCURSOR_SIZE environment variable and scale the cursor accordingly, but some quick experiments didn’t confirm this for mpv, alacritty and gedit.

Thanks for posting this. My mouse cursor would disappear whenever I opened Wezterm, but this brought it back… although I went with Vanilla-DMZ. Strangely enough, this cursor only works inside the window and then immediately switches back to GNOME’s default cursor outside of it.

For non-home-manager users, I think this is everything done in home-manager/modules/config/home-cursor.nix at e3ad5108f54177e6520535768ddbf1e6af54b59d · nix-community/home-manager · GitHub (the following assumes you want Adwaita size 24):

n.b. adding settings to .config/gtk-3.0/settings.ini was the only solution that worked for me.

  • $HOME/.config/gtk-3.0/settings.ini containing
  • Symbolic links in $HOME:
  └── default
      ├── Adwaita.source -> /home/me/.nix-profile/share/icons/Adwaita
      └── index.theme -> /home/me/.nix-profile/share/icons/Adwaita/index.theme
  • Same symbolic links in $HOME/.local/share/icons/default
  • $HOME/.Xresources containing
    Xcursor.theme: Adwaita
    Xcursor.size: 24
  • ${pkgs.xorg.xsetroot}/bin/xsetroot -xcf $HOME/.nix-profile/share/icons/Adwaita/cursors/left_ptr 24