Misterio77 / flavours

🎨💧 An easy to use base16 scheme manager that integrates with any workflow.
MIT License
501 stars 29 forks source link

feat: select subtemplate based on the scheme used #66

Closed dive-deeper closed 1 year ago

dive-deeper commented 1 year ago

Solves #65. It is not ideal, since I call find_template twice, but it gets the job done. I could change the find_template function to also receive the scheme as a parameter and give that back if a subtemplate with the scheme name is found, but well I'd like to first hear from you :)

Misterio77 commented 1 year ago

Hello! Thanks a lot for the contribution :D

It's a very valid usecase.

I was wondering if perhaps we could make this more explicit and transparent instead of it being implicit behaviour (a subtemplate/scheme name collision is unlikely, but very possible).

What if the user could use a {scheme} placeholder in their flavours configuration to refer to the scheme slug? That would make it work with any of the fields. For example, for your usecase (using scheme as subtemplate):

[[items]]
file = "~/.config/sway/config"
template = "sway"
subtemplate = "{scheme}"
hook = "swaymsg reload"

Would you be interested in making this change?

Misterio77 commented 1 year ago

The shell option does something similar with its {} placeholder, to support a variety of shells with different invocation syntaxes: https://github.com/Misterio77/flavours/blob/606817ef9d8e58235f37d19b1a5e1c340631e994/src/operations/apply.rs#L32

dive-deeper commented 1 year ago

Hey sorry, I was on holidays and just now came back. Thanks for your feedback! Sounds like a good idea with the {sheme} placeholder to make it more explicit. I'll implement it over the weekend :) I'd keep the behaviour that if no subtemplate with the scheme name/slug is found, then "default" is selected.

Misterio77 commented 1 year ago

Welcome back! Hope you rested well.

I'll implement it over the weekend

Thanks a lot!

dive-deeper commented 1 year ago

Didn't get to it last weekend, but have implemented it now. The search for a scheme dependent subtemplate now only happens if the subtemplate's value in the config is set to {scheme}. If no subtemplate with the name of the scheme is found, default is selected :) I tried to document the new option/behaviour. It's a little verbose, but couldn't describe it in less words...

Misterio77 commented 1 year ago

Looks good to me! Thanks a lot for the contribution (and sorry for the wait)!