Closed budRich closed 5 years ago
I have my polybar config set up something like this:
~/bin
polybarreload
~/.config/polybar
config
settings
theme
~/.config/mondo/generator/polybar/_mondo-template
~/.config/polybar/config
is the config file that polybar uses to render the actual bar. But i have moved everything except the "theme", to a file called settings, and the theme to a file called theme, then made a mondo template based on the theme file.
So whenever i want to change my polybar config, i do the changes to "settings" and then have a script (polybarrestart) that merge settings and theme into a new config, (the restart script also restarts polybar and some listener scripts).
cat ~/.config/polybar/settings ~/.config/polybar/theme > ~/.config/polybar/config
polybar-msg restart
I have similar things for other programs such as i3 and dunst. But I totally get what you are saying, and it is a good idea.
But it might have some side effects. If I would implement this, i would search the target file (let say polybar/config) for each line in _mono-template, but with mondo variables replaced by a regexp matching any word. This would probably work 99% of the time. But what if there are more then one matches or zero matches...
Another approach could be to add something like (lets take the polybar file as example again):
; >> date
[module/date]
type = internal/date
interval = 5
date =
date-alt = ""
time = %H:%M
time-alt = %m|%d
format-prefix =
label = %time%
; label-margin-left = 1
[settings]
screenchange-reload = true
; >> colors
; MONDO-BEGIN
[colors]
background = #8888c8
foreground = #FFFFE8
accent = #424242
alert = #b85c57
; MONDO-END
; >> settings
[bar/example]
font-0 = FixedFixedsys:style=Regular:size=12:antialias=false;1
notice the MONDO-START and MONDO-END, then i guess we would also need to add a _mondo-setting, like inject=true
.
And yeah, you get it, it would replace anything within the special blocks with the generated theme.
This second approach, will be much easier to predict, and i think i like it a lot. Also by using the settings variable, it will not break or change any existing mondo usage...
I will try to add this feature to the next mondo release.
Yeah regexing this seemed a lot messier to me as well. I really like the 2nd solution though, can't wait for it to be added!
@bl0nd test the newest release, the inject feature should work exact as described in my previous comment. https://github.com/budlabs/mondo-contrib/tree/master/lets/generator/polybar
@budRich Works like a charm, thanks for adding it!
np, thanks for bringing it up. I think i had thought about something like this before, but had some strange idea, keeping it simple, strict rules on what the program does and so on. But when you brought it up I gave it some more thought, and now when I have been using mondo quite a lost myself i know that this is a very common thing (to be able to only change parts of a config), and it totally makes sense and feels like a missing piece of the puzzle.
Please let me know if you got any other issues or feature requests for mondo.
Originally posted by @bl0nd in #6
every time I update a config file (say polybar's), I also have to update polybar's _mondo-template, otherwise when the former gets overwritten when I apply a theme, it'll be outdated by an edit. This updating gets a little tedious, especially when you got 4 or 5 other generators.
I thought it'd be a good idea to maybe have __mondo-template contain only lines from the original config that require substitution, so like for polybar:
~/.config/mondo/generators/polybar/_mondo-template
background = %%activebg%% background-alt = %%inactivebg%% foreground = %%activefg%% foreground-alt = %%inactivefg%% primary = %%blue%% secondary = %%yellow%% alert = %%red%% That way, whenever we update the original polybar config, we don't need to update the polybar _mondo-template. And to apply the theme, we'd just need to update the original config with the generated theme files instead of overwriting the entire original config. The only problem is I don't know how to do that just yet. I think diff could help but the real problem is how to replace the appropriate lines in the original config file.
I saw that your mondo-contrib repo was structured like this so I have no idea if this is already a feature? If it is, it hasn't worked for me so far (though maybe I'm just being dumb and messing up) so thought I'd just bring it up.