~/.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.
A line is one of:
# as its first character after any spaces;NAME=value, then optionally spaces or tabs and a # comment.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:
\ ` $ ; & | < > ( );'single quotes': anything but a ';"double quotes": anything but ", $, ` and \.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.
Bash would read it differently from the parsers, or run part of it as a command. So:
session/frametop-session.sh) checks the file with conf/ft_conf.py check before sourcing it. When a line is outside the grammar it doesn’t source the file: it loads the valid settings from ft_conf.py shell instead, which writes each one quoted, so nothing in the file runs. check exits 3 for bad lines; when the check itself can’t run (no python3, a Python error), the session sources the file as it always did.POINTER_IGNORE) are comma-separated, with no space after the comma. Readers trim spaces around items and drop empty ones. An item can’t contain a comma.[+-]digits[.digits][e[+-]digits]. Anything else (abc, 0x10, 1_000, inf) is a bad value: the program warns and uses the setting’s default. It never crashes, and C never reads garbage as 0.1 and 0, keywords lower-case (on, off, auto). The few readers that have always accepted any case of a keyword (GAZE_TRACKER, GAZE_EYE, EYES_SIZE_GUARD) still do; writers write lower-case.HANDS_NEAR=0 turns direct touch off in every reader (ft-screens, the pointer helper, the relay, Input Settings).Programs write a setting with ft_conf.set_value(NAME, value). It:
NAME (the one that counts, even if it’s outside the grammar), keeping its comment, or adds a line at the end; every other line stays as it is;A-Z a-z 0-9 _ . , : / @ % + = * ? ^ -, and in single quotes otherwise, so spaces, $(), ; and quotes in it are only text to bash;ValueError);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).