diff --git a/README.md b/README.md index 4f1fad9..9680e76 100644 --- a/README.md +++ b/README.md @@ -53,3 +53,5 @@ _ocat_ is a CLI driver for _recorder_: it prints data stored by the _recorder_ i The following environment variables control _ocat_'s behaviour: * `OCAT_FORMAT` can be set to the preferred output format. If unset, JSON is used. The `--format` option overrides this setting. +* `OCAT_USERNAME` can be set to the preferred username. The `--user` option overrides this environment variable. +* `OCAT_DEVICE` can be set to the preferred device name. The `--device` option overrides this environment variable. diff --git a/ocat.c b/ocat.c index a865493..c4f4bf3 100644 --- a/ocat.c +++ b/ocat.c @@ -103,6 +103,13 @@ int main(int argc, char **argv) time_t now, s_lo, s_hi; output_type otype = JSON; + if ((p = getenv("OCAT_USERNAME")) != NULL) { + username = strdup(p); + } + if ((p = getenv("OCAT_DEVICE")) != NULL) { + device = strdup(p); + } + if ((p = getenv("OCAT_FORMAT")) != NULL) { switch (tolower(*p)) { case 'j': otype = JSON; break;