mirror of
				https://codeberg.org/dwl/dwl.git
				synced 2025-11-04 05:54:14 +00:00 
			
		
		
		
	apply autostart patch from dwm
https://dwm.suckless.org/patches/cool_autostart/
This commit is contained in:
		
							parent
							
								
									803d24c266
								
							
						
					
					
						commit
						d05edf6760
					
				@ -93,6 +93,12 @@ LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE
 | 
				
			|||||||
static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
 | 
					static const enum libinput_config_accel_profile accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE;
 | 
				
			||||||
static const double accel_speed = 0.0;
 | 
					static const double accel_speed = 0.0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Autostart */
 | 
				
			||||||
 | 
					static const char *const autostart[] = {
 | 
				
			||||||
 | 
					        "sh", "-c", "swaybg --image /xap/local/background", NULL,
 | 
				
			||||||
 | 
					        NULL /* terminate */
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* If you want to use the windows key change this to WLR_MODIFIER_LOGO */
 | 
					/* If you want to use the windows key change this to WLR_MODIFIER_LOGO */
 | 
				
			||||||
#define MODKEY WLR_MODIFIER_ALT
 | 
					#define MODKEY WLR_MODIFIER_ALT
 | 
				
			||||||
#define TAGKEYS(KEY,SKEY,TAG) \
 | 
					#define TAGKEYS(KEY,SKEY,TAG) \
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										53
									
								
								dwl.c
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								dwl.c
									
									
									
									
									
								
							@ -232,6 +232,7 @@ static void arrange(Monitor *m);
 | 
				
			|||||||
static void arrangelayer(Monitor *m, struct wl_list *list,
 | 
					static void arrangelayer(Monitor *m, struct wl_list *list,
 | 
				
			||||||
		struct wlr_box *usable_area, int exclusive);
 | 
							struct wlr_box *usable_area, int exclusive);
 | 
				
			||||||
static void arrangelayers(Monitor *m);
 | 
					static void arrangelayers(Monitor *m);
 | 
				
			||||||
 | 
					static void autostartexec(void);
 | 
				
			||||||
static void axisnotify(struct wl_listener *listener, void *data);
 | 
					static void axisnotify(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void buttonpress(struct wl_listener *listener, void *data);
 | 
					static void buttonpress(struct wl_listener *listener, void *data);
 | 
				
			||||||
static void checkconstraintregion(void);
 | 
					static void checkconstraintregion(void);
 | 
				
			||||||
@ -419,6 +420,9 @@ static Atom netatom[NetLast];
 | 
				
			|||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
 | 
					/* compile-time check if all tags fit into an unsigned int bit array. */
 | 
				
			||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
 | 
					struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pid_t *autostart_pids;
 | 
				
			||||||
 | 
					static size_t autostart_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* function implementations */
 | 
					/* function implementations */
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
applybounds(Client *c, struct wlr_box *bbox)
 | 
					applybounds(Client *c, struct wlr_box *bbox)
 | 
				
			||||||
@ -447,6 +451,29 @@ applybounds(Client *c, struct wlr_box *bbox)
 | 
				
			|||||||
		c->geom.y = bbox->y;
 | 
							c->geom.y = bbox->y;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					autostartexec(void) {
 | 
				
			||||||
 | 
						const char *const *p;
 | 
				
			||||||
 | 
						size_t i = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* count entries */
 | 
				
			||||||
 | 
						for (p = autostart; *p; autostart_len++, p++)
 | 
				
			||||||
 | 
							while (*++p);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						autostart_pids = calloc(autostart_len, sizeof(pid_t));
 | 
				
			||||||
 | 
						for (p = autostart; *p; i++, p++) {
 | 
				
			||||||
 | 
							if ((autostart_pids[i] = fork()) == 0) {
 | 
				
			||||||
 | 
								setsid();
 | 
				
			||||||
 | 
								execvp(*p, (char *const *)p);
 | 
				
			||||||
 | 
								fprintf(stderr, "dwl: execvp %s\n", *p);
 | 
				
			||||||
 | 
								perror(" failed");
 | 
				
			||||||
 | 
								_exit(EXIT_FAILURE);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							/* skip arguments */
 | 
				
			||||||
 | 
							while (*++p);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
applyexclusive(struct wlr_box *usable_area,
 | 
					applyexclusive(struct wlr_box *usable_area,
 | 
				
			||||||
		uint32_t anchor, int32_t exclusive,
 | 
							uint32_t anchor, int32_t exclusive,
 | 
				
			||||||
@ -2067,6 +2094,16 @@ printstatus(void)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
quit(const Arg *arg)
 | 
					quit(const Arg *arg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						size_t i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/* kill child processes */
 | 
				
			||||||
 | 
						for (i = 0; i < autostart_len; i++) {
 | 
				
			||||||
 | 
							if (0 < autostart_pids[i]) {
 | 
				
			||||||
 | 
								kill(autostart_pids[i], SIGTERM);
 | 
				
			||||||
 | 
								waitpid(autostart_pids[i], NULL, 0);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wl_display_terminate(dpy);
 | 
						wl_display_terminate(dpy);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2162,6 +2199,7 @@ run(char *startup_cmd)
 | 
				
			|||||||
		die("startup: backend_start");
 | 
							die("startup: backend_start");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Now that the socket exists and the backend is started, run the startup command */
 | 
						/* Now that the socket exists and the backend is started, run the startup command */
 | 
				
			||||||
 | 
						autostartexec();
 | 
				
			||||||
	if (startup_cmd) {
 | 
						if (startup_cmd) {
 | 
				
			||||||
		int piperw[2];
 | 
							int piperw[2];
 | 
				
			||||||
		if (pipe(piperw) < 0)
 | 
							if (pipe(piperw) < 0)
 | 
				
			||||||
@ -2551,11 +2589,24 @@ sigchld(int unused)
 | 
				
			|||||||
	 * setting our own disposition for SIGCHLD.
 | 
						 * setting our own disposition for SIGCHLD.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	pid_t pid;
 | 
						pid_t pid;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (signal(SIGCHLD, sigchld) == SIG_ERR)
 | 
						if (signal(SIGCHLD, sigchld) == SIG_ERR)
 | 
				
			||||||
		die("can't install SIGCHLD handler:");
 | 
							die("can't install SIGCHLD handler:");
 | 
				
			||||||
	while (0 < (pid = waitpid(-1, NULL, WNOHANG)))
 | 
						while (0 < (pid = waitpid(-1, NULL, WNOHANG))) {
 | 
				
			||||||
 | 
							pid_t *p, *lim;
 | 
				
			||||||
		if (pid == child_pid)
 | 
							if (pid == child_pid)
 | 
				
			||||||
			child_pid = -1;
 | 
								child_pid = -1;
 | 
				
			||||||
 | 
							if (!(p = autostart_pids))
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							lim = &p[autostart_len];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (; p < lim; p++) {
 | 
				
			||||||
 | 
								if (*p == pid) {
 | 
				
			||||||
 | 
									*p = -1;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user