mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
conf: add 'title' conf option and --title command line option
This commit is contained in:
parent
57761fbd50
commit
ec7a768487
12 changed files with 65 additions and 2 deletions
|
|
@ -19,7 +19,8 @@
|
|||
the Wayland window.
|
||||
* `--app-id` command line option, that sets the _app-id_ property on
|
||||
the Wayland window.
|
||||
|
||||
* **title** option to `footrc`, that sets the initial window title.
|
||||
* `--title` command line option, that sets the initial window title.
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
|||
16
client.c
16
client.c
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ _arguments \
|
|||
'(-c --config)'{-c,--config}'[path to configuration file (XDG_CONFIG_HOME/footrc)]:config:_files' \
|
||||
'(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
|
||||
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
|
||||
'--title[initial window title]:()' \
|
||||
'(-a --app-id)'{-a,--app-id}'[value to set the app-id property on the Wayland window to (foot)]:()' \
|
||||
'--maximized[start in maximized mode]' \
|
||||
'--fullscreen[start in fullscreen mode]' \
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
_arguments \
|
||||
-s \
|
||||
'(-t --term)'{-t,--term}'[value to set the environment variable TERM to (foot)]:term:->terms' \
|
||||
'--title[initial window title]:()' \
|
||||
'(-a --app-id)'{-a,--app-id}'[value to set the app-id property on the Wayland window to (foot)]:()' \
|
||||
'--maximized[start in maximized mode]' \
|
||||
'--fullscreen[start in fullscreen mode]' \
|
||||
|
|
|
|||
7
config.c
7
config.c
|
|
@ -209,6 +209,11 @@ parse_section_main(const char *key, const char *value, struct config *conf,
|
|||
conf->login_shell = str_to_bool(value);
|
||||
}
|
||||
|
||||
else if (strcmp(key, "title") == 0) {
|
||||
free(conf->title);
|
||||
conf->title = strdup(value);
|
||||
}
|
||||
|
||||
else if (strcmp(key, "app-id") == 0) {
|
||||
free(conf->app_id);
|
||||
conf->app_id = strdup(value);
|
||||
|
|
@ -832,6 +837,7 @@ config_load(struct config *conf, const char *conf_path)
|
|||
*conf = (struct config) {
|
||||
.term = strdup("foot"),
|
||||
.shell = get_shell(),
|
||||
.title = strdup("foot"),
|
||||
.app_id = strdup("foot"),
|
||||
.width = 700,
|
||||
.height = 500,
|
||||
|
|
@ -966,6 +972,7 @@ config_free(struct config conf)
|
|||
{
|
||||
free(conf.term);
|
||||
free(conf.shell);
|
||||
free(conf.title);
|
||||
free(conf.app_id);
|
||||
tll_free_and_free(conf.fonts, free);
|
||||
free(conf.server_socket_path);
|
||||
|
|
|
|||
1
config.h
1
config.h
|
|
@ -10,6 +10,7 @@
|
|||
struct config {
|
||||
char *term;
|
||||
char *shell;
|
||||
char *title;
|
||||
char *app_id;
|
||||
bool login_shell;
|
||||
unsigned width;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@ execute (instead of the shell).
|
|||
*-t*,*--term*=_TERM_
|
||||
Value to set the environment variable *TERM* to. Default: _foot_.
|
||||
|
||||
*--title*=_TITLE:
|
||||
Initial window title. Default: _foot_.
|
||||
|
||||
*-a*,*--app-id*=_ID_
|
||||
Value to set the *app-id* property on the Wayland window
|
||||
to. Default: _foot_.
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@ in this order:
|
|||
*term*
|
||||
Value to set the environment variable *TERM* to. Default: _foot_.
|
||||
|
||||
*title*
|
||||
Initial window title. Default: _foot_.
|
||||
|
||||
*app-id*
|
||||
Value to set the *app-id* property on the Wayland window to. The
|
||||
compositor can use this value to e.g. group multiple windows, or
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ execute (instead of the shell).
|
|||
*-t*,*--term*=_TERM_
|
||||
Value to set the environment variable *TERM* to. Default: _foot_.
|
||||
|
||||
*--title*=_TITLE:
|
||||
Initial window title. Default: _foot_.
|
||||
|
||||
*-a*,*--app-id*=_ID_
|
||||
Value to set the *app-id* property on the Wayland window
|
||||
to. Default: _foot_.
|
||||
|
|
|
|||
11
main.c
11
main.c
|
|
@ -46,6 +46,7 @@ print_usage(const char *prog_name)
|
|||
" -c,--config=PATH load configuration from PATH (XDG_CONFIG_HOME/footrc)\n"
|
||||
" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
|
||||
" -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"
|
||||
|
|
@ -140,6 +141,7 @@ main(int argc, char *const *argv)
|
|||
static const struct option longopts[] = {
|
||||
{"config", required_argument, NULL, 'c'},
|
||||
{"term", required_argument, NULL, 't'},
|
||||
{"title", required_argument, NULL, 'T'},
|
||||
{"app-id", required_argument, NULL, 'a'},
|
||||
{"login-shell", no_argument, NULL, 'L'},
|
||||
{"font", required_argument, NULL, 'f'},
|
||||
|
|
@ -159,6 +161,7 @@ main(int argc, char *const *argv)
|
|||
|
||||
const char *conf_path = NULL;
|
||||
const char *conf_term = NULL;
|
||||
const char *conf_title = NULL;
|
||||
const char *conf_app_id = NULL;
|
||||
bool login_shell = false;
|
||||
tll(char *) conf_fonts = tll_init();
|
||||
|
|
@ -193,6 +196,10 @@ main(int argc, char *const *argv)
|
|||
login_shell = true;
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
conf_title = optarg;
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
conf_app_id = optarg;
|
||||
break;
|
||||
|
|
@ -313,6 +320,10 @@ main(int argc, char *const *argv)
|
|||
free(conf.term);
|
||||
conf.term = strdup(conf_term);
|
||||
}
|
||||
if (conf_title != NULL) {
|
||||
free(conf.title);
|
||||
conf.title = strdup(conf_title);
|
||||
}
|
||||
if (conf_app_id != NULL) {
|
||||
free(conf.app_id);
|
||||
conf.app_id = strdup(conf_app_id);
|
||||
|
|
|
|||
16
server.c
16
server.c
|
|
@ -74,6 +74,7 @@ client_destroy(struct client *client)
|
|||
/* TODO: clone server conf completely, so that we can just call
|
||||
* conf_destroy() here */
|
||||
free(client->conf.term);
|
||||
free(client->conf.title);
|
||||
free(client->conf.app_id);
|
||||
|
||||
free(client);
|
||||
|
|
@ -225,6 +226,19 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
|||
goto shutdown;
|
||||
}
|
||||
|
||||
CHECK_BUF(sizeof(uint16_t));
|
||||
uint16_t title_len = *(uint16_t *)p; p += sizeof(title_len);
|
||||
|
||||
CHECK_BUF(title_len);
|
||||
const char *title = (const char *)p; p += title_len;
|
||||
LOG_DBG("app-id = %.*s", title_len, title);
|
||||
|
||||
if (title_len != strlen(title) + 1) {
|
||||
LOG_ERR("title length mismatch: indicated = %hu, actual = %zu",
|
||||
title_len - 1, strlen(title));
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
CHECK_BUF(sizeof(uint16_t));
|
||||
uint16_t app_id_len = *(uint16_t *)p; p += sizeof(app_id_len);
|
||||
|
||||
|
|
@ -273,6 +287,8 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data)
|
|||
client->conf = *server->conf;
|
||||
client->conf.term = strlen(term_env) > 0
|
||||
? strdup(term_env) : strdup(server->conf->term);
|
||||
client->conf.title = strlen(title) > 0
|
||||
? strdup(title) : strdup(server->conf->title);
|
||||
client->conf.app_id = strlen(app_id) > 0
|
||||
? strdup(app_id) : strdup(server->conf->app_id);
|
||||
client->conf.login_shell = login_shell;
|
||||
|
|
|
|||
|
|
@ -795,7 +795,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
|||
if (!term_font_dpi_changed(term))
|
||||
goto err;
|
||||
|
||||
term_set_window_title(term, "foot");
|
||||
term_set_window_title(term, conf->title);
|
||||
|
||||
/* Let the Wayland backend know we exist */
|
||||
tll_push_back(wayl->terms, term);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue