regolith-linux / regolith-desktop

Meta package for the Regolith Desktop Environment
1.5k stars 31 forks source link

i3 config error on logout not reproducible on i3 reload #669

Closed p3k closed 2 years ago

p3k commented 2 years ago

On login I get an i3 alert about errors in the config – nevertheless, the settings seem to be applied correctly.

image

Furthermore, any later i3-msg reload or i3-msg restart does not produce the error alert.

I assume the problem is because of quotation marks:

image

Steps to reproduce the behavior

Use something like the following in Xresources and the i3 config, resp.

! ~/.config/regolith2/Xresources
#define q(x) #x
#define quote(x) q(x)
#define text_font quote(UbuntuCondensed 10)
#define glyph_font quote(BitstreamVeraSansMono Nerd Font 12)
#define workspace_name(index, color) index:<span> </span><span font_desc="UbuntuCondensed 10">index</span> <span font_desc="BitstreamVeraSansMono Nerd Font 12" foreground=color></span><span> </span>
#define color_yellow #f99b11

i3-wm.workspace.01.name: workspace_name(1, quote(color_yellow))
# ~/.config/regolith2/i3/99_custom
workspace "$ws1" output $primary

Expected behavior

There either should not be an error displayed after login, or it should be displayed all the time, i.e. when reloading / restarting i3, too.

Installation Details

Additional context

As I mentioned before I assume there is an issue about the quotation marks – would be glad if somebody could help me solve this.

p3k commented 2 years ago

i was wrong regarding the settings being correctly applied, must have been by chance or random that the workspaces appear on the desired monitor output.

also, the issue is indeed reproducible: i have to reload the Xresources file before restarting i3, though:

xrdb -remove
xrdb -merge ~/.config/regolith2/Xresource
i3-msg restart

anyway, the root cause obviously are quotation marks, i.e. an undesired premature ending of a quoted string:

"1:<span> </span><span font_desc='UbuntuCondensed 10'>9</span> <span font_desc='BitstreamVeraSansMono Nerd Font 12' foreground="#878787"></span><span> </span>" output DP-3
                                                                                                                               ↑       ↑
                                                                                                      these quotation marks should be escaped or replaced by single ones

does anyone have the missing clue for me how to achieve either escaping the quotation marks or replacing them by single ones, e.g. like this:

"1:<span> </span><span font_desc='UbuntuCondensed 10'>9</span> <span font_desc='BitstreamVeraSansMono Nerd Font 12' foreground='#878787'></span><span> </span>" output DP-3

here are the corresponding lines of my config again (slightly modified, i already replaced some double with single quotation marks):

! ~/.config/regolith2/Xresources
#define workspace_name(index, color) index:<span> </span><span font_desc='UbuntuCondensed 10'>index</span> <span font_desc='BitstreamVeraSansMono Nerd Font 12' foreground=color></span><span> </span>
#define color_yellow #f99b11
i3-wm.workspace.01.name: workspace_name(1, quote(color_yellow))
# ~/.config/regolith2/i3/99_custom
workspace "$ws1" output $primary

it basically boils down to the question: how can i output the color variable in the macro with escaped or single quotation marks?

p3k commented 2 years ago

i gave up too early, with the help from a so thread about the c preprocessor i was able to solve this puzzle:

! ~/.config/regolith2/Xresources
#define apos '
#define q2(a, x, b) a##x##b
#define q1(a, x, b) q2(a, x, b)
#define quote(x) q1(apos, x, apos)
#define workspace_name(index, color) index:<span> </span><span font_desc='UbuntuCondensed 10'>index</span> <span font_desc='BitstreamVeraSansMono Nerd Font 12' foreground=color></span><span> </span>
#define color_yellow #f99b11

i3-wm.workspace.01.name: workspace_name(1, quote(color_yellow))
kgilmer commented 2 years ago

You're a preprocessor power user @p3k ! Glad you got the issue resolved, closing.