Toml Bombadil

CI codecov crates.io aur

Toml Bombadil is a dotfile manager written in rust.

Why another dotfile manager ?

I wrote Toml Bombadil because I kept changing my desktop environment : switching from i3 to sway, from sway to xfce, from xfce to gnome and back to sway. When you keep changing your working environment like this you end up with several problems : - Some symlinks will end up orphans. - Not every program you use support Xresources and you will most probably have to manually edit some themes/config. - When starting a fresh installation you will very likely need to adapt your existing dotfiles to your new machine. - It is a mess

Toml Bombadil try to solve this with a simple addition to the symlink method used by other tools : instead of creating a symlink from a dotfile to the actual config path of a program, it will create a copy of it and symlink the copy. This additional step allow to use your original dotfile as a template and inject variables in the copy. You can have multiple value files in the same dotfile repository and change color scheme, or any value on the fly.

In addition this is completely optional, you could start using Toml Bombadil only to generate symlinks and templatize your dot file progressively.

Installation

Using cargo

shell script cargo install toml-bombadil

Archlinux

shell script yay -S bombadil-bin

Getting started

1. Setup :

By default Bombadil will look for a toml config file named bombadil.toml.

shell script git clone https://github.com/my_org/my_dotfiles cd my_dotfiles && touch bombadil.toml

If you are using git you might want to add .dots to your .gitignore.

2. Configuration :

```toml

{dotfiles}/bombadil.toml

Path to your dotfiles relative to your $HOME directory

dotfilesdir = "mydotfiles"

A dot entry representing a symlink, source is relative to dotfiles_dir

and target shall be relative to $HOME directory or absolute.

[[dot]] source = "sway" target = ".config/sway"

You can have as many dot entry as you want, linking files or directories

[[dot]] source = "alacritty" target = ".config/alacritty/alacritty.yml"

Var hold the path to a toml file containing the variables to inject in your templatize dotfiles

You can have multiple var files as long as variable names does not colide.

[[var]] # Optional path = "vars.toml"

Meta vars holds the definitive values for aliased variables. It allows to reuse and group variables.

[[meta]] # Optional path = "vars.toml"

Post install commands

[[hook]] # Optional command = "sway reload" ```

3. Linking bombadil :

For Bombadil to be able to run from any directory and use different config files we need to symlink bombadil config to $XDG_CONFIG_DIR/bombadil.toml :

shell script bombadil install -c my_dotfiles/bombadil.toml

If you want to switch to another config simply run : shell script bombadil install -c my_dotfiles/bombadil-i3.toml

4. Install template and symlink :

shell script bombadil link

This command will do the following : - Remove {dotfiles_dir}/.dots and any symlink pointing to a sub directory/file. - Inject variables (if you defined some) in a copy of dot entries listed in Bombadil config. - Write the copies to {dotfiles_dir}/.dots. - Symlink dot entries. - Run post install hooks.

Templatize you dotfiles

Variables

Now that your dot files are symlinked with Bombadil you can define some variables A Bombadil var files is a valid toml file containing only key with string values :

For example you have the following file in {dotfiles_dir}/vars.toml.

toml terminal = "alacritty" background = "#292C3E" foreground = "#EBEBEB" text = "#FF261E" cursor = "#FF261E" black = "#0d0d0d" red = "#FF301B" green = "#A0E521" yellow = "#FFC620" blue = "#1BA6FA"

You can use the var file by adding the following to your Bombadil config : toml [[var]] path = "vars.toml"

Let's say you have the following dot entry : toml [[dot]] source = "alacritty" target = ".config/alacritty/alacritty.yml"

alacritty.yaml color scheme could look like this : ```yaml ...

{dotfiles}/alacritty.yml

colors: primary: background: "[background]" foreground: "[foreground]" cursor: text: "[text]" cursor: "[cursor]" ... ```

And the output file actually linked to alacritty config would be this :

```yaml ...

{dotfiles}/.dots/alacritty.yml

colors: primary: background: "#292C3E" foreground: "#EBEBEB" cursor: text: "#FF261E" cursor: "#FF261E" ... ```

To update variables and the current config simply run bombadil link.

Meta variables

Sometimes it could be handy to use different variables names for the same values. For instance if you want to define a system wide color scheme, you could define the following meta variables :

```toml

bombadil.toml

[[meta]] path = "meta_vars.toml"

[[var]] path = "alacritty_vars.toml"

[[var]] path = "sway_vars.toml"

...

```

A meta variable configuration looks exactly like a variables configuration file. The only difference is that meta vars are intended to be used in other var files :

```toml

meta_vars.toml

metared = "#ff0000" metablack = "#000000" meta_green = "#008000" ```

```toml

sway_vars.toml

swayclientfocusedbackground = "metablack" swayclientfocused_border = "#ffff00"

...

```

```toml

alacritty_vars.toml

alacrittybackground = "metablack" alacrittycursor = "metagreen"

...

```

Example repositories

Contributing

Found a bug, have a suggestion for a new feature ? Please submit an issue.

License

All the code in this repository is released under the MIT License, for more information take a look at the LICENSE file.