SuperCuber / dotter

A dotfile manager and templater written in rust 🦀
The Unlicense
882 stars 46 forks source link

[FEATURE] Conditionally include files #52

Closed mythmon closed 3 years ago

mythmon commented 3 years ago

Is your feature request related to a problem? Please describe. I have some packages in my dotfiles that have integrations with other packages. For example, I use both taskwarrior and polybar, though not always both together. If I have both polybar and taskwarrior, I'd like to include an extra file in the polybar configuration, to be used to show data from taskwarrior.

Describe the solution you'd like It would be nice to be able to say something like

[polybar.files]
"polybar/taskwarrior.sh" = {
    target = "~/.config/polybar/taskwarrior.sh"
    depends = ["taskwarrior"]
    # or alternatively, some scripted condition
    if = "polybar in dotter.packages"
}

Describe alternatives you've considered I could make a seperate package, "polybar-taskwarrior", and include that anytime that I have both set up. That's an extra step though, and not as automatic.

SuperCuber commented 3 years ago

This definitely seems useful enough to implement, I'll consider some alternatives when I get to it.

SuperCuber commented 3 years ago

This is now implemented in master (as of commit https://github.com/SuperCuber/dotter/commit/17d9e5653037e3b95d541aea0df18d701499c321 ).

Usage is if = "condition", and the condition rendered as if you did {{#if condition_here}}, so you can use any variables and helpers, for example if = "(is_executable 'my_program')"

Please check it out and see if it works well for you.

mythmon commented 3 years ago

Sorry for the long delay, but I've finally gotten around to using this. It works great. I'm using it like

[polybar.files]
"polybar/config.handlebars" = "~/.config/polybar/config"
"polybar/config.d/taskwarrior" = { type="symbolic", target = "~/.config/polybar/config.d/taskwarrior", if = "dotter.packages.taskwarrior" }