conf: add 'title' conf option and --title command line option

This commit is contained in:
Daniel Eklöf 2020-04-01 19:59:47 +02:00
parent 57761fbd50
commit ec7a768487
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
12 changed files with 65 additions and 2 deletions

View file

@ -33,6 +33,7 @@ print_usage(const char *prog_name)
printf("\n");
printf("Options:\n");
printf(" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --title=TITLE initial window title (foot)\n"
" -a,--app-id=ID window application ID (foot)\n"
" --maximized start in maximized mode\n"
" --fullscreen start in fullscreen mode\n"
@ -51,6 +52,7 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"term", required_argument, NULL, 't'},
{"title", required_argument, NULL, 'T'},
{"app-id", required_argument, NULL, 'a'},
{"maximized", no_argument, NULL, 'm'},
{"fullscreen", no_argument, NULL, 'F'},
@ -63,6 +65,7 @@ main(int argc, char *const *argv)
};
const char *term = "";
const char *title = "";
const char *app_id = "";
const char *server_socket_path = NULL;
enum log_colorize log_colorize = LOG_COLORIZE_AUTO;
@ -80,6 +83,10 @@ main(int argc, char *const *argv)
term = optarg;
break;
case 'T':
title = optarg;
break;
case 'a':
app_id = optarg;
break;
@ -194,12 +201,14 @@ main(int argc, char *const *argv)
}
const uint16_t cwd_len = strlen(cwd) + 1;
const uint16_t term_len = strlen(term) + 1;
const uint16_t title_len = strlen(title) + 1;
const uint16_t app_id_len = strlen(app_id) + 1;
uint32_t total_len = 0;
/* Calculate total length */
total_len += sizeof(cwd_len) + cwd_len;
total_len += sizeof(term_len) + term_len;
total_len += sizeof(title_len) + title_len;
total_len += sizeof(app_id_len) + app_id_len;
total_len += sizeof(uint8_t); /* maximized */
total_len += sizeof(uint8_t); /* fullscreen */
@ -233,6 +242,13 @@ main(int argc, char *const *argv)
goto err;
}
if (send(fd, &title_len, sizeof(title_len), 0) != sizeof(title_len) ||
send(fd, title, title_len, 0) != title_len)
{
LOG_ERRNO("failed to send title to server");
goto err;
}
if (send(fd, &app_id_len, sizeof(app_id_len), 0) != sizeof(app_id_len) ||
send(fd, app_id, app_id_len, 0) != app_id_len)
{