-
Notifications
You must be signed in to change notification settings - Fork 5
Home
- It's good to read the Conventions before starting to write any variable files.
- If you're coming from whiskers, check Migration.
- If you're running into odd issues, check Common gotchas.
Zenbu elaborated (courtesy of fullsalvo)
zenbu
is a file templater written in python. It uses Jinja2 and YAML as
the base for file templating. This means that when you run it, it'll use
variables you've assigned to fill in fields in other files you've created
templates for. To be exact, zenbu uses the folder
$HOME/.config/zenbu/templates/
as a clone of your $HOME
directory.
Files within this folder are rewritten, filling in fields of the form {{ variable_name }}
with what variable_name
has been defined as within yaml
files. This gives you the power to rewrite configuration files on-the-fly then
reload your programs to update apperances almost instantly (or at least that's
how I use zenbu). The standard yaml file referenced is
$HOME/.config/zenbu/defaults.yaml
. Variations you make should be stored
in $HOME/.config/zenbu/variable_sets/
(which also allows you to nest
folders for better organization).
Let's have an example. Say you want to change your files to a theme in a file
bright.yaml
in your variable_sets
directory and you have one file in
your templates
directory, .Xresources
. In bright.yaml
, contents
might look something like
colors:
primary: "red"
secondary: "cyan"
background: "#F1F2E0"
foreground: "#695F6C"
cursor: "#695F6C"
black:
normal: "#695F6C"
bold: "#A5B9C4"
red:
normal: "#A75D4d"
bold: "#A75D4d"
green:
normal: "#A4D485"
bold: "#A4D485"
yellow:
normal: "#FDD485"
bold: "#FDD485"
blue:
normal: "#90AABE"
bold: "#90AABE"
magenta:
normal: "#B17FBC"
bold: "#B17FBC"
cyan:
normal: "#6BD6E3"
bold: "#6BD6E3"
white:
normal: "#A5B9C4"
bold: "#F1F2E0"
This is the typical structure for colors used in zenbu. Accessing nested elements can be a hassle, but this is something typically handled from within the defaults.yaml
file with a section for convenience, like
bgc: "{{ colors.background }}"
fgc: "{{ colors.foreground }}"
csc: "{{ colors.cursor }}"
n_black: "{{ colors.black.normal }}"
b_black: "{{ colors.black.bold }}"
n_red: "{{ colors.red.normal }}"
b_red: "{{ colors.red.bold }}"
n_green: "{{ colors.green.normal }}"
b_green: "{{ colors.green.bold }}"
n_yellow: "{{ colors.yellow.normal }}"
b_yellow: "{{ colors.yellow.bold }}"
n_blue: "{{ colors.blue.normal }}"
b_blue: "{{ colors.blue.bold }}"
n_magenta: "{{ colors.magenta.normal }}"
b_magenta: "{{ colors.magenta.bold }}"
n_cyan: "{{ colors.cyan.normal }}"
b_cyan: "{{ colors.cyan.bold }}"
n_white: "{{ colors.white.normal }}"
b_white: "{{ colors.white.bold }}"
n_primary: "{{ colors[colors.primary].normal }}"
b_primary: "{{ colors[colors.primary].bold }}"
n_secondary: "{{ colors[colors.secondary].normal }}"
b_secondary: "{{ colors[colors.secondary].bold }}"
Anyway, if .Xresources
looks something like
! Colors
*.borderColor: {{ bgc }}
*.background: {{ bgc }}
*.foreground: {{ fgc }}
*.cursorColor: {{ csc }}
! Black
*.color0: {{ n_black }}
*.color8: {{ b_black }}
! Red
*.color1: {{ n_red }}
*.color9: {{ b_red }}
! Green
*.color2: {{ n_green }}
*.color10: {{ b_green }}
! Yellow
*.color3: {{ n_yellow }}
*.color11: {{ b_yellow }}
! Blue
*.color4: {{ n_blue }}
*.color12: {{ b_blue }}
! Magenta
*.color5: {{ n_magenta }}
*.color13: {{ b_magenta }}
! Cyan
*.color6: {{ n_cyan }}
*.color14: {{ b_cyan }}
! White
*.color7: {{ n_white }}
*.color15: {{ b_white }}
Then the ultimately rewritten file from a call of zenbu bright
(zenbu will load from defaults.yaml
unless other yamls are called as arguments by their basename) would be in $HOME/.Xresources
as
! Colors
*.borderColor: #F1F2E0
*.background: #F1F2E0
*.foreground: #695F6C
*.cursorColor: #695F6C
! Black
*.color0: #695F6C
*.color8: #A5B9C4
! Red
*.color1: #A75D4d
*.color9: #A75D4d
! Green
*.color2: #A4D485
*.color10: #A4D485
! Yellow
*.color3: #FDD485
*.color11: #FDD485
! Blue
*.color4: #90AABE
*.color12: #90AABE
! Magenta
*.color5: #B17FBC
*.color13: #B17FBC
! Cyan
*.color6: #6BD6E3
*.color14: #6BD6E3
! White
*.color7: #A5B9C4
*.color15: #F1F2E0
This process only rewrites the file, however. If you want functionality with reloading like metakirby5 and fullsalvo have, you need to use scripting, like a script in wz-utils, rhisk
. This was designed for whizkers
, so you'll need to substitute with zenbu
as necessary.
This example is only the tip of the iceberg of what zenbu can be used for. If you want to understand all its power, start messing around with it yourself! Have fun!