summaryrefslogtreecommitdiff
path: root/dwl/dwl-patches/patches/systemd/systemd-0.7.patch
blob: f911997a976ac08e41cbf4566a4ff3a4f134e5b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From 43b3026b0744d54287eada71c84ea8be174950c3 Mon Sep 17 00:00:00 2001
From: Shringe <dashingkoso@gmail.com>
Date: Sat, 12 Jul 2025 01:00:46 -0500
Subject: [PATCH] basic implementation

---
 dwl.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/dwl.c b/dwl.c
index c717c1d..4ba134d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -680,6 +680,15 @@ cleanup(void)
 	wlr_xwayland_destroy(xwayland);
 	xwayland = NULL;
 #endif
+	/* Stop systemd target */
+	if (fork() == 0) {
+		setsid();
+		execvp("systemctl", (char *const[]) {
+			"systemctl", "--user", "stop", "dwl-session.target", NULL
+		});
+		exit(1);
+	}
+
 	wl_display_destroy_clients(dpy);
 	if (child_pid > 0) {
 		kill(-child_pid, SIGTERM);
@@ -2222,6 +2231,31 @@ run(char *startup_cmd)
 		die("startup: display_add_socket_auto");
 	setenv("WAYLAND_DISPLAY", socket, 1);
 
+	/* Import environment variables then start systemd target */
+	if (fork() == 0) {
+		setsid();
+		
+		/* First: import environment variables */
+		pid_t import_pid = fork();
+		if (import_pid == 0) {
+			execvp("systemctl", (char *const[]) {
+				"systemctl", "--user", "import-environment", 
+				"DISPLAY", "WAYLAND_DISPLAY", NULL
+			});
+			exit(1);
+		}
+		
+		/* Wait for import to complete */
+		waitpid(import_pid, NULL, 0);
+		
+		/* Second: start target */
+		execvp("systemctl", (char *const[]) {
+			"systemctl", "--user", "start", "dwl-session.target", NULL
+		});
+		
+		exit(1);
+	}
+
 	/* Start the backend. This will enumerate outputs and inputs, become the DRM
 	 * master, etc */
 	if (!wlr_backend_start(backend))
-- 
2.49.0