New config format in r2000

Easier config and more DSL magic
Added by Christoph Kappel about 5 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:


 1 COLORS = {
 2   :fg_panel => "#757575" 
 3 }
 5 TAGS = {
 6   "terms" => "xterm|[u]?rxvt",
 7   "float" => { :regex => "display", :float => true }
 9 }


1 color :fg_panel, "#757575" 
3 tag "terms", "xterm|[u]?rxvt" 
5 tag "float" do
6   regex "display" 
7   float true
8 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.