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:
https://github.com/hyprwm/Hyprland/issues/1577#issuecomment-1436033647

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:
https://www.reddit.com/r/kde/comments/sumh0u/comment/j95h75o/

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:

2 Likes

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
  [Settings]
  gtk-cursor-theme-name=Adwaita
  gtk-cursor-theme-size=24
  • Symbolic links in $HOME:
  .icons
  └── 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
1 Like

I have revisited this as well and found

  • I already had exec configure-gtk Adwaita in my Sway config.
  • When hovering over Waybar and xterm I think I had the Adwaita theme and cursor size 24
  • I think configure-gtk doesn’t let me specify a cursor size
  • When hovering over Alacritty or mpv the cursor was tiny. It was also tiny when hovering over Sway’s gaps between windows.
  • I found Mouse Cursor Tiny · Issue #4610 · swaywm/sway · GitHub which suggested to add seat * xcursor_theme Adwaita 32 to Sway config, and this works for Alacritty and mpv windows and gaps between windows.
  • I still need to figure out how to increase the size from 24 to 32 on Waybar and Xterm, but it’s already way better than before
  • Setting XCURSOR_SIZE as suggested in Cursor themes - ArchWiki didn’t have an effect
  • Setting Xcursor.size: 32 in ~/.Xresources didn’t have any effect.
  • I don’t have the $HOME/.nix-profile/share/icons/Adwaita that is described in the previous post
  • Trying to modify the cursor size via $HOME/.config/gtk-3.0/settings.ini didn’t have an effect. But maybe that’s because I don’t have the theme in my home folder.