djpohly / dwl

dwm for Wayland - ARCHIVE: development has moved to Codeberg
https://codeberg.org/dwl/dwl
Other
1.93k stars 284 forks source link

[Question] How to set xcursor theme #442

Closed idr4n closed 1 year ago

idr4n commented 1 year ago

Sorry for the silly question. I have been trying to change the cursor so it is consistent with the gtk cursor globally.

I have changed cursor_mgr = wlr_xcursor_manager_create(NULL, 24); to cursor_mgr = wlr_xcursor_manager_create("BreezeX-Light", 48); in dwl.c, and although the cursor size has changed permanently to "48", still the cursor theme is not "BreezeX-Light" in applications such as kitty and alacritty.

Additonally, in an autostart script (used with the autostart patch) I have set

export XCURSOR_SIZE=48

gnome-schema=org.gnome.desktop.interface
gsettings set $gnome-schema cursor-theme 'BreezeX-Light'
gsettings set $gnome-schema cursor-size '48'

Will appreciate to be pointed in the right direction. Thanks in advance!

pm4rcin commented 1 year ago

From what I understand the theme applies everywhere but terminals? Would you check it on foot terminal since it's the most minimal and probably different from kitty and alacritty? If it doesn't apply on foot too it could be wlroots bug or something with how terminals work.

dnkl commented 1 year ago

The cursor is rendered by the client under Wayland, and up until very recently, there were no Wayland protocol to broadcast the selected theme to the clients.

This meant that all applications, or toolkits, had their own way of determining which theme to use. For example, gsettings for GTK applications.

I don't know exactly what setting the theme in wlroots does, but I'd guess it just sets the theme used by the compositor itself (i.e. for compositor rendered surfaces), and possibly for XWayland.

Foot currently uses the XCURSOR_THEME and XCURESOR_SIZE environment variables to determine the cursor theme. These should be set by the compositor. I known Sway does this, but not sure if it's done in wlroots, or in Sway.

The next release of wayland-protocols (1.32?), will bring a new protocol, for server side cursors. Once compositors, and clients, implement this protocol, clients no longer need to worry about the xcursor theme. See https://wayland.app/protocols/cursor-shape-v1.

idr4n commented 1 year ago

Thanks a lot for your reply @pm4rcin and @dnkl.

I have tried it on the foot terminal and I still get a different cursor. It does seem to be happening only in terminal apps, and in dwlb bar. In the terminals the cursor size is at least the right one but when hovering on dwlb bar the cursor theme and size is the default one.

As far as I know, other window managers handle this, for example in River, riverctl xcursor-theme BreezeX-Light 48 does the trick, and in Sway and Hypr, seat * xcursor_theme BreezeX-Light 48 , and hyprctl setcursor BreezeX-Light 48, respectively.

Thanks again!

dnkl commented 1 year ago

I know they River and Sway export XCURSOR_THEME and XCURSOR_SIZE when you configure the theme. I would assume hyperlnd does the same.

idr4n commented 1 year ago

@dnkl, yes, based on Sway's code that command basically sets the env variable XCURSOR_THEME. So adding this to dwl.c basically makes the cursor behave as expected:

cursor_mgr = wlr_xcursor_manager_create("BreezeX-Light", 48);
setenv("XCURSOR_THEME", "BreezeX-Light", 1);
setenv("XCURSOR_SIZE", "48", 1);

The only exception is still when hovering the status bar managed by dwlb. I will ask in their repo why this might be.

Thanks again!