mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-22 05:33:45 -04:00
main: allow server socket path to be set on the command line
This adds an optional argument to -s,--server that allows the user to override the default socket path (XDG_RUNTIME_DIR/foot.sock).
This commit is contained in:
parent
89ea61cf0c
commit
44f24b01bc
1 changed files with 9 additions and 3 deletions
12
main.c
12
main.c
|
|
@ -38,12 +38,14 @@ static void
|
||||||
print_usage(const char *prog_name)
|
print_usage(const char *prog_name)
|
||||||
{
|
{
|
||||||
printf("Usage: %s [OPTIONS]...\n", prog_name);
|
printf("Usage: %s [OPTIONS]...\n", prog_name);
|
||||||
|
printf("Usage: %s [OPTIONS]... -- command\n", prog_name);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Options:\n");
|
printf("Options:\n");
|
||||||
printf(" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
|
printf(" -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"
|
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
|
||||||
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
|
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
|
||||||
" -s,--server run as a server (use 'footclient' to start terminals)\n"
|
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
|
||||||
|
" Without PATH, XDG_RUNTIME_DIR/foot.sock will be used.\n"
|
||||||
" -v,--version show the version number and quit\n");
|
" -v,--version show the version number and quit\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +81,7 @@ main(int argc, char *const *argv)
|
||||||
{"term", required_argument, 0, 't'},
|
{"term", required_argument, 0, 't'},
|
||||||
{"font", required_argument, 0, 'f'},
|
{"font", required_argument, 0, 'f'},
|
||||||
{"geometry", required_argument, 0, 'g'},
|
{"geometry", required_argument, 0, 'g'},
|
||||||
{"server", no_argument, 0, 's'},
|
{"server", optional_argument, 0, 's'},
|
||||||
{"version", no_argument, 0, 'v'},
|
{"version", no_argument, 0, 'v'},
|
||||||
{"help", no_argument, 0, 'h'},
|
{"help", no_argument, 0, 'h'},
|
||||||
{NULL, no_argument, 0, 0},
|
{NULL, no_argument, 0, 0},
|
||||||
|
|
@ -88,7 +90,7 @@ main(int argc, char *const *argv)
|
||||||
bool as_server = false;
|
bool as_server = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
int c = getopt_long(argc, argv, ":t:f:g:vh", longopts, NULL);
|
int c = getopt_long(argc, argv, ":t:f:g:s::vh", longopts, NULL);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -135,6 +137,10 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
as_server = true;
|
as_server = true;
|
||||||
|
if (optarg != NULL) {
|
||||||
|
free(conf.server_socket_path);
|
||||||
|
conf.server_socket_path = strdup(optarg);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'v':
|
case 'v':
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue