commit b9b73721a1cc87c9a6b8d68f0529e2c273f3440a
parent 1d97676cf31728fbc5a9dd798da1f6ba1b0f9618
Author: lumidify <nobody@lumidify.org>
Date:   Sun, 22 May 2022 21:16:12 +0200
Add command line argument to prevent daemonizing
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/ltkd.c b/src/ltkd.c
@@ -102,6 +102,8 @@ static ltk_timer *timers = NULL;
 static size_t timers_num = 0;
 static size_t timers_alloc = 0;
 
+static int daemonize_flag = 1;
+
 static int ltk_mainloop(ltk_window *window);
 static char *get_sock_path(char *basedir, Window id);
 static FILE *open_log(char *dir);
@@ -139,11 +141,14 @@ static ltk_window *main_window = NULL;
 int main(int argc, char *argv[]) {
 	int ch;
 	char *title = "LTK Window";
-	while ((ch = getopt(argc, argv, "t:")) != -1) {
+	while ((ch = getopt(argc, argv, "dt:")) != -1) {
 		switch (ch) {
 			case 't':
 				title = optarg;
 				break;
+			case 'd':
+				daemonize_flag = 0;
+				break;
 			default:
 				ltk_fatal("USAGE: ltkd [-t title]\n");
 		}
@@ -197,7 +202,8 @@ ltk_mainloop(ltk_window *window) {
 
 	printf("%lu", window->xwindow);
 	fflush(stdout);
-	daemonize();
+	if (daemonize_flag)
+		daemonize();
 
 	/* FIXME: make time management smarter - maybe always figure out how long
 	   it will take until the next timer is due and then sleep if no other events