Loop your X cursor around the screen 👉😎👉
git clone https://github.com/m-col/xoop
Files | Refs | Readme | License

Commit fc91bb73cb8250524fe865c4e69e10b45d1c21d2
Parent: 76f9291b532537750c2797f6ae2e8e4a01bfcc4c
Author: mcol <mcol@posteo.net>
Date: 2020-04-20 12:20:47 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2020-04-20 12:20:47 +0100

add argparsing with forking option

xoop.c Modified

@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <xcb/xcb.h>
 #include <xcb/shape.h>
+#include <unistd.h>
 
 #ifdef DEBUG
 #include <stdio.h>
@@ -182,16 +183,37 @@
 }
 
 
-int main()
+int main(int argc, char *argv[])
 {
+    int opt;
+    int to_fork = 0;
+    int pid;
     xcb_window_t wid;
 
+    while ((opt = getopt(argc, argv, "f")) != -1) {
+        switch (opt) {
+	    case 'f':
+		to_fork = 1;
+		break;
+        }
+    }
+
     conn = xcb_connect(NULL, NULL);
     if (xcb_connection_has_error(conn))
-	exit(1);
-    screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
+	exit(EXIT_FAILURE);
 
+    screen = xcb_setup_roots_iterator(xcb_get_setup(conn)).data;
     wid = setup_window();
+
+    if (to_fork) {
+	pid = fork();
+	if (pid > 0) {
+	    exit(EXIT_SUCCESS);
+	} else if (pid < 0) {
+	    exit(EXIT_FAILURE);
+	}
+    }
+
     event_loop();
 
     xcb_unmap_window(conn, wid);