bakkeby / dusk

Just another fork of dwm
MIT License
154 stars 21 forks source link

Dusk and dmenu #16

Closed kmarzic closed 1 year ago

kmarzic commented 1 year ago

Hi,

It looks like that dusk is using default colors for dmenu instead of specific theme colors (e.g. solarized-light.res).

Patches used by dmenu:

me@machine:~/git/suckless/dmenu-flexipatch (master) $ diff patches.def.h patches.h | grep "^>"
> #define ALPHA_PATCH 1
> #define HIGHLIGHT_PATCH 1
> #define INITIALTEXT_PATCH 1
> #define XRESOURCES_PATCH 1
me@machine:~/git/suckless/dmenu-flexipatch (master) $

Xdefaults includes:

me@machine:~$ cat ~/.Xdefaults
...
#include "git/suckless/dusk.resources/themes/light/solarized-light.res"
#include "git/suckless/dusk.resources/themes/template.txt"
...
me@machine:~$

Xdefaults dmenu variables:

me@machine:~$ xrdb -query | grep dmenu
dmenu.adjacent.bg.color:        #dc322f
dmenu.adjacent.fg.color:        #002b36
dmenu.border.bg.color:  #fdf6e3
dmenu.hp.bg.color:      #268bd2
dmenu.hp.fg.color:      #fdf6e3
dmenu.norm.bg.color:    #fdf6e3
dmenu.norm.fg.color:    #586e75
dmenu.normhl.bg.color:  #b58900
dmenu.normhl.fg.color:  #fdf6e3
dmenu.out.bg.color:     #b58900
dmenu.out.fg.color:     #fdf6e3
dmenu.prompt.bg.color:  #fdf6e3
dmenu.prompt.fg.color:  #586e75
dmenu.sel.bg.color:     #dc322f
dmenu.sel.fg.color:     #002b36
dmenu.selhl.bg.color:   #2aa198
dmenu.selhl.fg.color:   #002b36
me@machine:~$

In dmenu process output, used are default colors (defined in config.h in dusk directory) and not from xresources :

me@machine:~$ while [ 1 ]; do ps -auxwww | grep dmenu | grep -v grep; sleep 1; done
kmarzic   190403  0.0  0.0  19328 10272 ?        S    17:32   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #180A13 -nf #BE89AE -sb #440000 -sf #FFF7D4
kmarzic   190403  5.0  0.0  19328 10272 ?        S    17:32   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #180A13 -nf #BE89AE -sb #440000 -sf #FFF7D4
kmarzic   190403  2.5  0.0  19328 10272 ?        S    17:32   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #180A13 -nf #BE89AE -sb #440000 -sf #FFF7D4
^C

Best regards

bakkeby commented 1 year ago

Thanks for reporting, I'll consider this as a genuine bug.

We have bespoke resource strings being configured like this:

https://github.com/bakkeby/dusk/blob/052bc0ebd126d6b000502399fdb9a1ce1c9b578f/config.def.h#L121-L128

Unintuitively, these resource strings will be prefixed with dusk. when they are looked up. This was actually intentional in order for all resource strings used to be specific to the window manager.

E.g. the config of:

    { "mfact", FLOAT, &mfact },

would be defined as:

dusk.mfact: 0.35

This was also to allow for a different colour scheme to be used for other uses of dmenu while sticking with a similar look and feel when triggering dmenu_run via the window manager.

The cause of dusk using the default colours when spawning dmenu in this case is that the resource templates do not define resources such as dusk.dmenu.norm.bg.color.

To address this I am going to drop the behaviour of prefixing the resource string defined in the resources array. That seems overall more intuitive as well as more flexible.


NB: the passing of -fn, -nb, -nf, -sb and -sf arguments to dmenu is primarily to be in line with what dwm is doing, i.e. it should work just fine with any version of dmenu.

If you use the Xresources patch for dmenu then in principle you would not need any of this.

On that topic the dmenu resource strings that are exposed in template.txt are specific to my bespoke build of dmenu. The resource strings used in dmenu-flexipatch expand on the pattern defined in the original xresources patch.

If you use dmenu-flexipatch then you may want to adjust the template to use the resource strings from that build instead.

! === dmenu colors ===
dmenu.foreground:                     BASE_FOREGROUND
dmenu.background:                     BASE_BACKGROUND
dmenu.selforeground:                  SELECTED_FOREGROUND
dmenu.selbackground:                  SELECTED_BACKGROUND
dmenu.bordercolor:                    BORDER
dmenu.outforeground:                  MARKED_FG_COLOR
dmenu.outbackground:                  MARKED_BG_COLOR
dmenu.midforeground:                  SELECTED_FOREGROUND
dmenu.midbackground:                  SELECTED_BACKGROUND
dmenu.selhlforeground:                URGENT_FG_COLOR
dmenu.selhlbackground:                URGENT_BG_COLOR
dmenu.hlforeground:                   MARKED_FG_COLOR
dmenu.hlbackground:                   MARKED_BG_COLOR
#ifdef WARNING_FG_COLOR
dmenu.hpforeground:                   WARNING_FG_COLOR
#endif
#ifdef WARNING_BG_COLOR
dmenu.hpbackground:                   WARNING_BG_COLOR
#endif
kmarzic commented 1 year ago

Hi,

Thanks @bakkeby for fix! It seems it is working now: dmenu is showing colors defined in Xresources.

Quick test (colors from solarized-light.res theme):

$ while [ 1 ]; do ps -auxwww | grep dmenu | grep -v grep; sleep 1; done
admkrem+ 1900206  0.0  0.0  17944  6152 ?        R    06:30   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #fdf6e3 -nf #586e75 -sb #dc322f -sf #002b36
admkrem+ 1900206  5.0  0.0  21892  8932 ?        S    06:30   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #fdf6e3 -nf #586e75 -sb #dc322f -sf #002b36
admkrem+ 1900206  2.5  0.0  21892  8932 ?        S    06:30   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #fdf6e3 -nf #586e75 -sb #dc322f -sf #002b36
admkrem+ 1900206  1.6  0.0  21892  8932 ?        S    06:30   0:00 dmenu -fn DejaVuSansMono Nerd Font:size=10:antialias=true:autohint=true:style=regular -nb #fdf6e3 -nf #586e75 -sb #dc322f -sf #002b36
^C

Closing this issue...

kmarzic commented 1 year ago

Working now, closing this issue...