diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-12-29 17:19:13 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-12-29 17:19:13 +0100 |
commit | f65f2d30fdad1a960ba1028fefbb51807532688e (patch) | |
tree | 660035c3cba4fb74b345b276fae3caa7f5f76de5 | |
parent | d90b3174d28504bb4b95724c39ec93fb0bebd7dc (diff) |
Make user homepath optional in setup-gsr-ui
-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(); |