From 44f24b01bc4fb77806b992e57a6c91121bd93bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 14 Dec 2019 12:59:54 +0100 Subject: [PATCH] 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). --- main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index ed426d4b..938aa992 100644 --- a/main.c +++ b/main.c @@ -38,12 +38,14 @@ static void print_usage(const char *prog_name) { printf("Usage: %s [OPTIONS]...\n", prog_name); + printf("Usage: %s [OPTIONS]... -- command\n", prog_name); printf("\n"); printf("Options:\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" " -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"); } @@ -79,7 +81,7 @@ main(int argc, char *const *argv) {"term", required_argument, 0, 't'}, {"font", required_argument, 0, 'f'}, {"geometry", required_argument, 0, 'g'}, - {"server", no_argument, 0, 's'}, + {"server", optional_argument, 0, 's'}, {"version", no_argument, 0, 'v'}, {"help", no_argument, 0, 'h'}, {NULL, no_argument, 0, 0}, @@ -88,7 +90,7 @@ main(int argc, char *const *argv) bool as_server = false; 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) break; @@ -135,6 +137,10 @@ main(int argc, char *const *argv) case 's': as_server = true; + if (optarg != NULL) { + free(conf.server_socket_path); + conf.server_socket_path = strdup(optarg); + } break; case 'v':