aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-12-29 17:19:13 +0100
committerdec05eba <dec05eba@protonmail.com>2024-12-29 17:19:13 +0100
commitf65f2d30fdad1a960ba1028fefbb51807532688e (patch)
tree660035c3cba4fb74b345b276fae3caa7f5f76de5
parentd90b3174d28504bb4b95724c39ec93fb0bebd7dc (diff)
Make user homepath optional in setup-gsr-ui
-rw-r--r--main.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main.c b/main.c
index 4a46f54..23b6104 100644
--- a/main.c
+++ b/main.c
@@ -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();