Compare commits
5 Commits
f90eea39df
...
7a754e4c6d
Author | SHA1 | Date | |
---|---|---|---|
|
7a754e4c6d | ||
|
6b59c9ea96 | ||
|
8cb984e3a6 | ||
|
03ebdd7bc6 | ||
|
66e12ff91d |
11
config.def.h
11
config.def.h
@ -31,6 +31,14 @@ static const unsigned int alphas[][3] = {
|
||||
/* fg bg border*/
|
||||
[SchemeNorm] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeSel] = { OPAQUE, baralpha, borderalpha },
|
||||
[SchemeHid] = { OPAQUE, baralpha, borderalpha },
|
||||
};
|
||||
|
||||
static const char *const autostart[] = {
|
||||
"picom", NULL,
|
||||
"unclutter", NULL,
|
||||
"dwmblocks", NULL,
|
||||
NULL /* terminate */
|
||||
};
|
||||
|
||||
/* tagging */
|
||||
@ -77,7 +85,8 @@ static const Layout layouts[] = {
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
|
||||
{ Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
|
84
dwm.c
84
dwm.c
@ -273,6 +273,8 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void xinitvisual();
|
||||
static void zoom(const Arg *arg);
|
||||
static void swaptags(const Arg *arg);
|
||||
static void autostart_exec(void);
|
||||
|
||||
static pid_t getparentprocess(pid_t p);
|
||||
static int isdescprocess(pid_t p, pid_t c);
|
||||
@ -343,6 +345,34 @@ struct Pertag {
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
/* dwm will keep pid's of processes from autostart array and kill them at quit */
|
||||
static pid_t *autostart_pids;
|
||||
static size_t autostart_len;
|
||||
|
||||
/* execute command from autostart array */
|
||||
static void
|
||||
autostart_exec() {
|
||||
const char *const *p;
|
||||
size_t i = 0;
|
||||
|
||||
/* count entries */
|
||||
for (p = autostart; *p; autostart_len++, p++)
|
||||
while (*++p);
|
||||
|
||||
autostart_pids = malloc(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, "dwm: execvp %s\n", *p);
|
||||
perror(" failed");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
/* skip arguments */
|
||||
while (*++p);
|
||||
}
|
||||
}
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applyrules(Client *c)
|
||||
@ -1401,7 +1431,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
XFree(data);
|
||||
}
|
||||
setclienttagprop(c);
|
||||
|
||||
c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||
c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
if (!c->isfloating)
|
||||
@ -1415,6 +1446,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
|
||||
if (!HIDDEN(c))
|
||||
setclientstate(c, NormalState);
|
||||
if (selmon->sel && selmon->sel->isfullscreen)
|
||||
setfullscreen(selmon->sel, 0);
|
||||
if (c->mon == selmon)
|
||||
unfocus(selmon->sel, 0);
|
||||
c->mon->sel = c;
|
||||
@ -1651,13 +1684,20 @@ quit(const Arg *arg)
|
||||
// fix: reloading dwm keeps all the hidden clients hidden
|
||||
Monitor *m;
|
||||
Client *c;
|
||||
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);
|
||||
}
|
||||
}
|
||||
for (m = mons; m; m = m->next) {
|
||||
if (m) {
|
||||
for (c = m->stack; c; c = c->next)
|
||||
if (c && HIDDEN(c)) showwin(c);
|
||||
}
|
||||
}
|
||||
|
||||
if(arg->i) restart = 1;
|
||||
running = 0;
|
||||
}
|
||||
@ -2023,6 +2063,7 @@ void
|
||||
setup(void)
|
||||
{
|
||||
int i;
|
||||
pid_t pid;
|
||||
XSetWindowAttributes wa;
|
||||
Atom utf8string;
|
||||
struct sigaction sa;
|
||||
@ -2034,7 +2075,21 @@ setup(void)
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
|
||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
|
||||
pid_t *p, *lim;
|
||||
|
||||
if (!(p = autostart_pids))
|
||||
continue;
|
||||
lim = &p[autostart_len];
|
||||
|
||||
for (; p < lim; p++) {
|
||||
if (*p == pid) {
|
||||
*p = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
signal(SIGHUP, sighup);
|
||||
signal(SIGTERM, sigterm);
|
||||
@ -3070,6 +3125,28 @@ zoom(const Arg *arg)
|
||||
arrange(c->mon);
|
||||
}
|
||||
|
||||
void
|
||||
swaptags(const Arg *arg)
|
||||
{
|
||||
unsigned int newtag = arg->ui & TAGMASK;
|
||||
unsigned int curtag = selmon->tagset[selmon->seltags];
|
||||
|
||||
if (newtag == curtag || !curtag || (curtag & (curtag-1)))
|
||||
return;
|
||||
|
||||
for (Client *c = selmon->clients; c != NULL; c = c->next) {
|
||||
if((c->tags & newtag) || (c->tags & curtag))
|
||||
c->tags ^= curtag ^ newtag;
|
||||
|
||||
if(!c->tags) c->tags = newtag;
|
||||
}
|
||||
|
||||
selmon->tagset[selmon->seltags] = newtag;
|
||||
|
||||
focus(NULL);
|
||||
arrange(selmon);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -3084,6 +3161,7 @@ main(int argc, char *argv[])
|
||||
if (!(xcon = XGetXCBConnection(dpy)))
|
||||
die("dwm: cannot get xcb connection\n");
|
||||
checkotherwm();
|
||||
autostart_exec();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath proc exec ps", NULL) == -1)
|
||||
|
12
patches/behavior/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
12
patches/behavior/dwm-alwayscenter-20200625-f04cac6.diff
Normal file
@ -0,0 +1,12 @@
|
||||
diff -up dwm/dwm.c dwmmod/dwm.c
|
||||
--- dwm/dwm.c 2020-06-25 00:21:30.383692180 -0300
|
||||
+++ dwmmod/dwm.c 2020-06-25 00:20:35.643692330 -0300
|
||||
@@ -1057,6 +1057,8 @@ manage(Window w, XWindowAttributes *wa)
|
||||
updatewindowtype(c);
|
||||
updatesizehints(c);
|
||||
updatewmhints(c);
|
||||
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
|
||||
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
if (!c->isfloating)
|
133
patches/functions/dwm-cool-autostart-20240312-9f88553.diff
Normal file
133
patches/functions/dwm-cool-autostart-20240312-9f88553.diff
Normal file
@ -0,0 +1,133 @@
|
||||
From feeaa839d2c6c1d0e66649cb64c4added563d4e4 Mon Sep 17 00:00:00 2001
|
||||
From: Son Phan Trung <phantrungson17@gmail.com>
|
||||
Date: Tue, 12 Mar 2024 18:37:32 +0700
|
||||
Subject: [PATCH] patches/cool-autostart: Update patch
|
||||
|
||||
Updated for the removal of the sigchld() function.
|
||||
---
|
||||
config.def.h | 5 +++++
|
||||
dwm.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
2 files changed, 61 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index 9efa774..aba210d 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -18,6 +18,11 @@ static const char *colors[][3] = {
|
||||
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||
};
|
||||
|
||||
+static const char *const autostart[] = {
|
||||
+ "st", NULL,
|
||||
+ NULL /* terminate */
|
||||
+};
|
||||
+
|
||||
/* tagging */
|
||||
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index f1d86b2..c2eb07d 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -233,6 +233,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
+static void autostart_exec(void);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -274,6 +275,34 @@ static Window root, wmcheckwin;
|
||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||
|
||||
+/* dwm will keep pid's of processes from autostart array and kill them at quit */
|
||||
+static pid_t *autostart_pids;
|
||||
+static size_t autostart_len;
|
||||
+
|
||||
+/* execute command from autostart array */
|
||||
+static void
|
||||
+autostart_exec() {
|
||||
+ const char *const *p;
|
||||
+ size_t i = 0;
|
||||
+
|
||||
+ /* count entries */
|
||||
+ for (p = autostart; *p; autostart_len++, p++)
|
||||
+ while (*++p);
|
||||
+
|
||||
+ autostart_pids = malloc(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, "dwm: execvp %s\n", *p);
|
||||
+ perror(" failed");
|
||||
+ _exit(EXIT_FAILURE);
|
||||
+ }
|
||||
+ /* skip arguments */
|
||||
+ while (*++p);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/* function implementations */
|
||||
void
|
||||
applyrules(Client *c)
|
||||
@@ -1258,6 +1287,16 @@ propertynotify(XEvent *e)
|
||||
void
|
||||
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);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
running = 0;
|
||||
}
|
||||
|
||||
@@ -1540,6 +1579,7 @@ void
|
||||
setup(void)
|
||||
{
|
||||
int i;
|
||||
+ pid_t pid;
|
||||
XSetWindowAttributes wa;
|
||||
Atom utf8string;
|
||||
struct sigaction sa;
|
||||
@@ -1551,7 +1591,21 @@ setup(void)
|
||||
sigaction(SIGCHLD, &sa, NULL);
|
||||
|
||||
/* clean up any zombies (inherited from .xinitrc etc) immediately */
|
||||
- while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
|
||||
+ pid_t *p, *lim;
|
||||
+
|
||||
+ if (!(p = autostart_pids))
|
||||
+ continue;
|
||||
+ lim = &p[autostart_len];
|
||||
+
|
||||
+ for (; p < lim; p++) {
|
||||
+ if (*p == pid) {
|
||||
+ *p = -1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
/* init screen */
|
||||
screen = DefaultScreen(dpy);
|
||||
@@ -2152,6 +2206,7 @@ main(int argc, char *argv[])
|
||||
if (!(dpy = XOpenDisplay(NULL)))
|
||||
die("dwm: cannot open display");
|
||||
checkotherwm();
|
||||
+ autostart_exec();
|
||||
setup();
|
||||
#ifdef __OpenBSD__
|
||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||
--
|
||||
2.44.0
|
||||
|
68
patches/functions/dwm-swaptags-6.2.diff
Normal file
68
patches/functions/dwm-swaptags-6.2.diff
Normal file
@ -0,0 +1,68 @@
|
||||
From 9513cc776dc8114967988d4abc32fd7f37446ddb Mon Sep 17 00:00:00 2001
|
||||
From: fossy <fossy@dnmx.org>
|
||||
Date: Sun, 28 Nov 2021 21:34:37 +0100
|
||||
Subject: [PATCH] Move function and it's prototype from config.def.h to dwm.c
|
||||
|
||||
---
|
||||
config.def.h | 3 ++-
|
||||
dwm.c | 23 +++++++++++++++++++++++
|
||||
2 files changed, 25 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/config.def.h b/config.def.h
|
||||
index a2ac963..f31a66d 100644
|
||||
--- a/config.def.h
|
||||
+++ b/config.def.h
|
||||
@@ -50,7 +50,8 @@ static const Layout layouts[] = {
|
||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
|
||||
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
|
||||
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
|
||||
+ { Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} },
|
||||
|
||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||
diff --git a/dwm.c b/dwm.c
|
||||
index 5e4d494..d11addd 100644
|
||||
--- a/dwm.c
|
||||
+++ b/dwm.c
|
||||
@@ -234,6 +234,7 @@ static int xerror(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrordummy(Display *dpy, XErrorEvent *ee);
|
||||
static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||
static void zoom(const Arg *arg);
|
||||
+static void swaptags(const Arg *arg);
|
||||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
@@ -2127,6 +2128,28 @@ zoom(const Arg *arg)
|
||||
pop(c);
|
||||
}
|
||||
|
||||
+void
|
||||
+swaptags(const Arg *arg)
|
||||
+{
|
||||
+ unsigned int newtag = arg->ui & TAGMASK;
|
||||
+ unsigned int curtag = selmon->tagset[selmon->seltags];
|
||||
+
|
||||
+ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
|
||||
+ return;
|
||||
+
|
||||
+ for (Client *c = selmon->clients; c != NULL; c = c->next) {
|
||||
+ if((c->tags & newtag) || (c->tags & curtag))
|
||||
+ c->tags ^= curtag ^ newtag;
|
||||
+
|
||||
+ if(!c->tags) c->tags = newtag;
|
||||
+ }
|
||||
+
|
||||
+ selmon->tagset[selmon->seltags] = newtag;
|
||||
+
|
||||
+ focus(NULL);
|
||||
+ arrange(selmon);
|
||||
+}
|
||||
+
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
--
|
||||
2.34.1
|
||||
|
Loading…
Reference in New Issue
Block a user