add config + command line option for setting initial window width/height

This commit is contained in:
Daniel Eklöf 2019-08-23 17:26:41 +02:00
parent 4e2067446a
commit 7026f60717
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 56 additions and 13 deletions

View file

@ -159,6 +159,19 @@ parse_section_main(const char *key, const char *value, struct config *conf,
conf->shell = strdup(value);
}
else if (strcmp(key, "geometry") == 0) {
unsigned width, height;
if (sscanf(value, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
LOG_ERR(
"%s: %d: expected WIDTHxHEIGHT, where both are positive integers: %s",
path, lineno, value);
return false;
}
conf->width = width;
conf->height = height;
}
else if (strcmp(key, "font") == 0) {
char *copy = strdup(value);
for (const char *font = strtok(copy, ","); font != NULL; font = strtok(NULL, ","))
@ -440,6 +453,8 @@ config_load(struct config *conf)
*conf = (struct config) {
.term = strdup("foot"),
.shell = get_shell(),
.width = -1,
.height = -1,
.fonts = tll_init(),
.scrollback_lines = 1000,