Project

General

Profile

unexist.dev

subtle

Assorted tidbits and projects

New config format in r2000

Easier config and more DSL magic
Added by Christoph Kappel almost 14 years ago

Let's talk about the config in subtle:

Currently there are hashes, almost everything is a hash. This brings some benefits, especially for Ruby experts but also can be annoying for more complex things like a tag definition - even for me. On the contrary we have sublets with a fancy DSL so why not adding a DSL for the config too?

In fact there was a longer discussion about this topic in #subtle, there were votes for and votes against it but overall all agreed that there must be something new. After some thinking and talking there was and a consent and here is a comparison of the old and the new config:

{{column(:start)}}

Hash

COLORS = {
  :fg_panel => "#757575" 
}

TAGS = {
  "terms" => "xterm|[u]?rxvt",
  "float" => { :regex => "display", :float => true }

}

{{column(:mid)}}

DSL

color :fg_panel, "#757575" 

tag "terms", "xterm|[u]?rxvt" 

tag "float" do
  regex "display" 
  float true
end

{{column(:end)}}

The advantage of the new way should be clear, it's easy and even more readable. Another thing is the new DSL isn't limited to the config, it can also be used in sublets. So what about sublets that bring some own bindings?

Ok, but what does this mean for you?

It means migration from your old config to a new or using the new default config. This can be a annoying task, but to ease this there is a migration script that comes with subtle. It will be installed to /usr/share/subtle/scripts/migrate.rb and can be run like:

ruby /usr/share/subtle/scripts/migrate.rb

This will automatically migrate your config, please make sure with subtle -k that the new config is fine before starting subtle. This script should cover most of the trivial things and create a backup of the older config typically $XDG_CONFIG_HOME/subtle/subtle.rb.old or ~/.config/subtle/subtle.rb.old.


Comments