diff options
-rw-r--r-- | main.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -119,7 +119,7 @@ static int copy_file_atomic_set_capabilities(const char *source_path, const char static void usage(void) { fprintf(stderr, "usage alt.1: kms-server-proxy <initial_socket_path> <card_path> <user_homepath>\n"); - fprintf(stderr, "usage alt.2: kms-server-proxy setup-gsr-ui <user_homepath>\n"); + fprintf(stderr, "usage alt.2: kms-server-proxy setup-gsr-ui [user_homepath]\n"); exit(1); } @@ -130,6 +130,12 @@ static int setup_gsr_ui(const char *user_homepath) { return 1; } + if(!user_homepath) { + user_homepath = getenv("HOME"); + if(!user_homepath) + user_homepath = "/tmp"; + } + char kms_server_proxy_local_filepath[PATH_MAX]; /* Update kms-server-proxy-N to kms-server-proxy-N+1 on update (update that needs to run before this program launches itself) */ snprintf(kms_server_proxy_local_filepath, sizeof(kms_server_proxy_local_filepath), "%s/.local/share/gpu-screen-recorder/kms-server-proxy-1", user_homepath); @@ -205,9 +211,10 @@ static int launch_gsr_kms_server(const char *initial_socket_path, const char *ca } int main(int argc, char **argv) { - if(argc == 3) { + if(argc == 2 || argc == 3) { + const char *user_homepath = argc == 3 ? argv[2] : NULL; if(strcmp(argv[1], "setup-gsr-ui") == 0) { - return setup_gsr_ui(argv[2]); + return setup_gsr_ui(user_homepath); } else { fprintf(stderr, "error: invalid option \"%s\".\n", argv[1]); usage(); |