frametop

frametop.conf

~/.config/frametop.conf holds Frametop’s settings as NAME=value lines. session/frametop.conf.example lists every key and what it does. This page says how the file is written, so that the session (which sources it with bash) and every other program (which parse it) read the same thing.

One parser per language reads it: conf/ft_conf.py for Python and conf/ft_conf.h for C and C++. conf/test/conf-test.py runs the Python, C and C++ readers, and bash, on the same test vectors (conf/test/vectors.json). Don’t add another parser: import one of these.

The grammar

A line is one of:

NAME is upper-case letters, digits and _, not starting with a digit. Lower-case names are the session script’s own variables, and a few upper-case ones are bash’s (UID, EUID, PPID, SHELLOPTS, BASHOPTS and BASH_VERSINFO are read-only, so setting one stopped the session; IFS, PATH, HOME, CDPATH, ENV, EXECIGNORE, FUNCNEST, GLOBIGNORE, OPTIND, POSIXLY_CORRECT, PS4, TMOUT and every BASH_* name change how its shell runs): a line setting one of them is outside the grammar. Spaces may come before the name, but none around the =: HANDS_NEAR = 0 isn’t a setting (bash would run a program called HANDS_NEAR).

The value is literal. It’s made of these, side by side with nothing between them:

So 'a b'c is a bc, and a ' inside a value is written '"'"' ('it'"'"'s' is it's). A # inside a value is part of it (a#b); only a # after whitespace starts a comment. The value ends at the first space or tab outside quotes.

Readers don’t expand anything: $HOME, $(...), backquotes and backslashes are outside the grammar, and ~ stays ~ (bash turns a leading ~ into the home folder; the programs that take a path, such as HANDS_FLAG_DIR, do the same). Bash also expands ~user, and a ~ after a :, which no reader does: don’t write those. Writers quote any value with a ~.

The last line of a name counts, as it does for bash.

Lines are separated by newlines. A carriage return or NUL anywhere in a line puts it outside the grammar.

A line outside the grammar

Bash would read it differently from the parsers, or run part of it as a command. So:

Values

Writing

Programs write a setting with ft_conf.set_value(NAME, value). It:

Writers don’t lock: two programs writing at the same moment can still lose one change.

The FT_<NAME> environment variables override the file in the session and in the programs that say so (ft_conf_setting, ft_conf::Setting).