Compare commits

...

6 Commits

Author SHA1 Message Date
164ff48dd4 movestack patch 2024-05-24 20:29:54 -04:00
d00a5f3227 also reset nmaster w/ reset layout 2024-05-24 20:29:54 -04:00
1e391a31fd reset layout patch 2024-05-24 20:29:54 -04:00
Jakub
90da2ddac4 Replace "no border patch" with remove border patch
This reverts commit e6862bb55b.
2024-05-24 20:29:54 -04:00
Jakub
b0c010ec9a exit menu patch 2024-05-24 20:29:54 -04:00
f463bb987f Add launchers patch to bottom bar
- removed left extra status
- removed/renamed some l/r specific variables
2024-05-24 20:29:45 -04:00
11 changed files with 702 additions and 94 deletions

View File

@ -44,6 +44,15 @@ static const char *const autostart[] = {
/* tagging */ /* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
/* launcher commands (They must be NULL terminated) */
static const char* browser[] = { "firefox", "--newwindow", "search.brave.com", NULL };
static const char* terminal[] = { "st", NULL };
static const Launcher launchers[] = {
{ terminal, "st" },
{ browser, "firefox" }
};
static const unsigned int ulinepad = 5; /* horizontal padding between the underline and tag */ static const unsigned int ulinepad = 5; /* horizontal padding between the underline and tag */
static const unsigned int ulinestroke = 2; /* thickness / height of the underline */ static const unsigned int ulinestroke = 2; /* thickness / height of the underline */
static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */ static const unsigned int ulinevoffset = 0; /* how far above the bottom of the bar the line should appear */
@ -95,7 +104,7 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL }; static const char *termcmd[] = { "st", NULL };
#include "exitdwm.c"
static const Key keys[] = { static const Key keys[] = {
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
@ -107,10 +116,13 @@ static const Key keys[] = {
{ MODKEY, XK_k, focusstackvis, {.i = -1 } }, { MODKEY, XK_k, focusstackvis, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } }, { MODKEY|ShiftMask, XK_j, focusstackhid, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } }, { MODKEY|ShiftMask, XK_k, focusstackhid, {.i = -1 } },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_r, resetlayout, {0} },
{ MODKEY, XK_Return, zoom, {0} }, { MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} }, { MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} },
@ -138,8 +150,8 @@ static const Key keys[] = {
TAGKEYS( XK_7, 6) TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7) TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8) TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} }, { MODKEY|ShiftMask, XK_e, exitdwm, {0} }
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
}; };
/* button definitions */ /* button definitions */

149
dwm.c
View File

@ -163,6 +163,12 @@ typedef struct {
int monitor; int monitor;
} Rule; } Rule;
typedef struct {
const char** command;
const char* name;
} Launcher;
/* function declarations */ /* function declarations */
static void applyrules(Client *c); static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@ -212,11 +218,13 @@ static void maprequest(XEvent *e);
static void monocle(Monitor *m); static void monocle(Monitor *m);
static void motionnotify(XEvent *e); static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg); static void movemouse(const Arg *arg);
static void movestack(const Arg *arg);
static Client *nexttiled(Client *c); static Client *nexttiled(Client *c);
static void pop(Client *c); static void pop(Client *c);
static void propertynotify(XEvent *e); static void propertynotify(XEvent *e);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h); static Monitor *recttomon(int x, int y, int w, int h);
static void resetlayout(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact); static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h); static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg); static void resizemouse(const Arg *arg);
@ -239,7 +247,6 @@ static void showwin(Client *c);
static void showhide(Client *c); static void showhide(Client *c);
static void sighup(int unused); static void sighup(int unused);
static void sigterm(int unused); static void sigterm(int unused);
static int solitary(Client *c);
static void spawn(const Arg *arg); static void spawn(const Arg *arg);
static void tag(const Arg *arg); static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
@ -286,8 +293,7 @@ static pid_t winpid(Window w);
static Client *prevzoom = NULL; static Client *prevzoom = NULL;
static const char broken[] = "broken"; static const char broken[] = "broken";
static char stext[256]; static char stext[256];
static char estextl[256]; static char estext[256];
static char estextr[256];
static char wfsymbol[2]; static char wfsymbol[2];
static int screen; static int screen;
static int sw, sh; /* X display screen geometry width, height */ static int sw, sh; /* X display screen geometry width, height */
@ -619,6 +625,18 @@ buttonpress(XEvent *e)
arg.v = c; arg.v = c;
} }
} }
} else if (ev->window == selmon->extrabarwin) {
i = x = 0;
for(i = 0; i < LENGTH(launchers); i++) {
x += TEXTW(launchers[i].name);
if (ev->x < x) {
Arg a;
a.v = launchers[i].command;
spawn(&a);
return;
} else if (ev->x > selmon->ww - TEXTW(estext))
click = ClkStatusText;
}
} else if ((c = wintoclient(ev->window))) { } else if ((c = wintoclient(ev->window))) {
focus(c); focus(c);
restack(selmon); restack(selmon);
@ -991,10 +1009,17 @@ drawbar(Monitor *m)
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
/* clear default bar draw buffer by drawing a blank rectangle */ /* clear default bar draw buffer by drawing a blank rectangle */
drw_rect(drw, 0, 0, m->ww, bh, 1, 1); drw_rect(drw, 0, 0, m->ww, bh, 1, 1);
etwr = TEXTW(estextr) - lrpad + 2; /* 2px right padding */ w = TEXTW(estext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - etwr - 2 * sp, 0, etwr, bh, 0, estextr, 0); drw_text(drw, m->ww - w - 2 * sp, 0, w, bh, 0, estext, 0);
etwl = TEXTW(estextl);
drw_text(drw, 0, 0, etwl + 2 * sp, bh, 0, estextl, 0); x = 0;
for (i = 0; i < LENGTH(launchers); i++)
{
w = TEXTW(launchers[i].name);
drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, 0 );
x += w;
}
drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh); drw_map(drw, m->extrabarwin, 0, 0, m->ww, bh);
} }
@ -1069,11 +1094,7 @@ focus(Client *c)
detachstack(c); detachstack(c);
attachstack(c); attachstack(c);
grabbuttons(c, 1); grabbuttons(c, 1);
/* Avoid flickering when another client appears and the border
* is restored */
if (!solitary(c)) {
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
}
setfocus(c); setfocus(c);
} else { } else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@ -1632,6 +1653,55 @@ nexttiled(Client *c)
return c; return c;
} }
void
movestack(const Arg *arg) {
Client *c = NULL, *p = NULL, *pc = NULL, *i;
if(arg->i > 0) {
/* find the client after selmon->sel */
for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
if(!c)
for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
}
else {
/* find the client before selmon->sel */
for(i = selmon->clients; i != selmon->sel; i = i->next)
if(ISVISIBLE(i) && !i->isfloating)
c = i;
if(!c)
for(; i; i = i->next)
if(ISVISIBLE(i) && !i->isfloating)
c = i;
}
/* find the client before selmon->sel and c */
for(i = selmon->clients; i && (!p || !pc); i = i->next) {
if(i->next == selmon->sel)
p = i;
if(i->next == c)
pc = i;
}
/* swap c and selmon->sel selmon->clients in the selmon->clients list */
if(c && c != selmon->sel) {
Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
selmon->sel->next = c->next==selmon->sel?c:c->next;
c->next = temp;
if(p && p != c)
p->next = c;
if(pc && pc != selmon->sel)
pc->next = selmon->sel;
if(selmon->sel == selmon->clients)
selmon->clients = c;
else if(c == selmon->clients)
selmon->clients = selmon->sel;
arrange(selmon);
}
}
void void
pop(Client *c) pop(Client *c)
{ {
@ -1716,6 +1786,19 @@ recttomon(int x, int y, int w, int h)
return r; return r;
} }
void
resetlayout(const Arg *arg)
{
Arg default_layout = {.v = &layouts[0]};
Arg default_mfact = {.f = mfact + 1};
setlayout(&default_layout);
setmfact(&default_mfact);
selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = nmaster;
arrange(selmon);
}
void void
resize(Client *c, int x, int y, int w, int h, int interact) resize(Client *c, int x, int y, int w, int h, int interact)
{ {
@ -1727,17 +1810,29 @@ void
resizeclient(Client *c, int x, int y, int w, int h) resizeclient(Client *c, int x, int y, int w, int h)
{ {
XWindowChanges wc; XWindowChanges wc;
unsigned int n;
Client *nbc;
c->oldx = c->x; c->x = wc.x = x; c->oldx = c->x; c->x = wc.x = x;
c->oldy = c->y; c->y = wc.y = y; c->oldy = c->y; c->y = wc.y = y;
c->oldw = c->w; c->w = wc.width = w; c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h; c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw; wc.border_width = c->bw;
if (solitary(c)) {
if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next)))
resetlayout(NULL);
for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
} else {
if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
wc.border_width = 0;
c->w = wc.width += c->bw * 2; c->w = wc.width += c->bw * 2;
c->h = wc.height += c->bw * 2; c->h = wc.height += c->bw * 2;
wc.border_width = 0;
} }
}
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c); configure(c);
XSync(dpy, False); XSync(dpy, False);
@ -2240,15 +2335,6 @@ sigterm(int unused)
quit(&a); quit(&a);
} }
int
solitary(Client *c)
{
return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
|| &monocle == c->mon->lt[c->mon->sellt]->arrange)
&& !c->isfullscreen && !c->isfloating
&& NULL != c->mon->lt[c->mon->sellt]->arrange;
}
void void
spawn(const Arg *arg) spawn(const Arg *arg)
{ {
@ -2755,21 +2841,14 @@ updatestatus(void)
char text[768]; char text[768];
if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) { if (!gettextprop(root, XA_WM_NAME, text, sizeof(text))) {
strcpy(stext, "dwm-"VERSION); strcpy(stext, "dwm-"VERSION);
estextl[0] = '\0'; estext[0] = '\0';
estextr[0] = '\0';
} else { } else {
char *l = strchr(text, statussep); char *s = strchr(text, statussep);
if (l) { if (s) {
*l = '\0'; l++; *s = '\0'; s++;
strncpy(estextl, l, sizeof(estextl) - 1); strncpy(estext, s, sizeof(estext) - 1);
} else } else
estextl[0] = '\0'; estext[0] = '\0';
char *r = strchr(estextl, statussep);
if (r) {
*r = '\0'; r++;
strncpy(estextr, r, sizeof(estextr) - 1);
} else
estextr[0] = '\0';
strncpy(stext, text, sizeof(stext) - 1); strncpy(stext, text, sizeof(stext) - 1);
} }
for(m = mons; m; m = m->next) for(m = mons; m; m = m->next)

87
exitdwm.c Normal file
View File

@ -0,0 +1,87 @@
# include <stdio.h>
# include <string.h>
void exitdwm ()
{
# if \
defined S_LOCK || \
defined S_RESTART_DWM || \
defined S_OFFSCREEN || \
defined S_EXIT || \
defined S_REBOOT || \
defined S_SHUTDOWN || \
defined S_LOCK_ICON || \
defined S_RESTART_DWM_ICON || \
defined S_OFFSCREEN_ICON || \
defined S_EXIT_ICON || \
defined S_REBOOT_ICON || \
defined S_SHUTDOWN_ICON || \
defined S_FORMAT || \
defined S_FORMAT_CLEAR
# error (conflicting macro names)
# endif
# define S_LOCK "Lock"
# define S_RESTART_DWM "restart Dwm"
# define S_OFFSCREEN "Off-screen"
# define S_EXIT "Exit"
# define S_REBOOT "Reboot"
# define S_SHUTDOWN "Shutdown"
# define S_LOCK_ICON "\uf023" // <= FontAwesome icons
# define S_RESTART_DWM_ICON "\uf01e"
# define S_OFFSCREEN_ICON "\uf108"
# define S_EXIT_ICON "\uf2f5"
# define S_REBOOT_ICON "\uf021"
# define S_SHUTDOWN_ICON "\uf011"
# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
# define S_FORMAT_CLEAR "sed 's/^..//'"
FILE * exit_menu = popen (
"echo \""
S_FORMAT (LOCK) "\n"
S_FORMAT (RESTART_DWM) "\n"
S_FORMAT (OFFSCREEN) "\n"
S_FORMAT (EXIT) "\n"
S_FORMAT (REBOOT) "\n"
S_FORMAT (SHUTDOWN)
"\" | dmenu -p exit: | " S_FORMAT_CLEAR
,
"r"
);
char exit_action [16];
if (
exit_menu == NULL ||
fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF
) {
fputs ("Error. Failure in exit_dwm.", stderr);
goto close_streams;
}
if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep .5; xset dpms force off");
else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1});
else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off");
else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0});
else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot");
else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i");
close_streams:
pclose (exit_menu);
# undef S_LOCK
# undef S_RESTART_DWM
# undef S_OFFSCREEN
# undef S_EXIT
# undef S_REBOOT
# undef S_SHUTDOWN
# undef S_LOCK_ICON
# undef S_RESTART_DWM_ICON
# undef S_OFFSCREEN_ICON
# undef S_EXIT_ICON
# undef S_REBOOT_ICON
# undef S_SHUTDOWN_ICON
# undef S_FORMAT
# undef S_FORMAT_CLEAR
}

View File

@ -1,53 +0,0 @@
diff --git dwm.c dwm.c
index 0fc328a..4a767bd 100644
--- dwm.c
+++ dwm.c
@@ -206,6 +206,7 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void sigchld(int unused);
+static int solitary(Client *c);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
@@ -802,7 +803,11 @@ focus(Client *c)
detachstack(c);
attachstack(c);
grabbuttons(c, 1);
- XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ /* Avoid flickering when another client appears and the border
+ * is restored */
+ if (!solitary(c)) {
+ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
+ }
setfocus(c);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
@@ -1288,6 +1293,11 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+ if (solitary(c)) {
+ c->w = wc.width += c->bw * 2;
+ c->h = wc.height += c->bw * 2;
+ wc.border_width = 0;
+ }
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);
@@ -1642,6 +1652,15 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG));
}
+int
+solitary(Client *c)
+{
+ return ((nexttiled(c->mon->clients) == c && !nexttiled(c->next))
+ || &monocle == c->mon->lt[c->mon->sellt]->arrange)
+ && !c->isfullscreen && !c->isfloating
+ && NULL != c->mon->lt[c->mon->sellt]->arrange;
+}
+
void
spawn(const Arg *arg)
{

View File

@ -0,0 +1,31 @@
diff --git a/dwm.c b/dwm.c
index 5646a5c..27e29df 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1283,12 +1283,26 @@ void
resizeclient(Client *c, int x, int y, int w, int h)
{
XWindowChanges wc;
+ unsigned int n;
+ Client *nbc;
c->oldx = c->x; c->x = wc.x = x;
c->oldy = c->y; c->y = wc.y = y;
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+
+ for (n = 0, nbc = nexttiled(c->mon->clients); nbc; nbc = nexttiled(nbc->next), n++);
+
+ if (c->isfloating || c->mon->lt[c->mon->sellt]->arrange == NULL) {
+ } else {
+ if (c->mon->lt[c->mon->sellt]->arrange == monocle || n == 1) {
+ wc.border_width = 0;
+ c->w = wc.width += c->bw * 2;
+ c->h = wc.height += c->bw * 2;
+ }
+ }
+
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);

View File

@ -0,0 +1,58 @@
diff --git a/config.def.h b/config.def.h
index 1c0b587..961a189 100644
--- a/config.def.h
+++ b/config.def.h
@@ -70,6 +70,7 @@ static Key keys[] = {
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY, XK_r, reorganizetags, {0} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
diff --git a/dwm.c b/dwm.c
index 4465af1..723d675 100644
--- a/dwm.c
+++ b/dwm.c
@@ -188,6 +188,7 @@ static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
+static void reorganizetags(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
@@ -1265,6 +1266,33 @@ recttomon(int x, int y, int w, int h)
return r;
}
+void
+reorganizetags(const Arg *arg) {
+ Client *c;
+ unsigned int occ, unocc, i;
+ unsigned int tagdest[LENGTH(tags)];
+
+ occ = 0;
+ for (c = selmon->clients; c; c = c->next)
+ occ |= (1 << (ffs(c->tags)-1));
+ unocc = 0;
+ for (i = 0; i < LENGTH(tags); ++i) {
+ while (unocc < i && (occ & (1 << unocc)))
+ unocc++;
+ if (occ & (1 << i)) {
+ tagdest[i] = unocc;
+ occ &= ~(1 << i);
+ occ |= 1 << unocc;
+ }
+ }
+
+ for (c = selmon->clients; c; c = c->next)
+ c->tags = 1 << tagdest[ffs(c->tags)-1];
+ if (selmon->sel)
+ selmon->tagset[selmon->seltags] = selmon->sel->tags;
+ arrange(selmon);
+}
+
void
resize(Client *c, int x, int y, int w, int h, int interact)
{

View File

@ -0,0 +1,65 @@
From 4df827a2ec7820f41bdb8576cc39b55fbf35be44 Mon Sep 17 00:00:00 2001
From: Jack Bird <jack.bird@durham.ac.uk>
Date: Mon, 16 Aug 2021 23:25:16 +0100
Subject: [PATCH] Patch applies cleanly
---
config.def.h | 1 +
dwm.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/config.def.h b/config.def.h
index 1c0b587..5d118cf 100644
--- a/config.def.h
+++ b/config.def.h
@@ -70,6 +70,7 @@ static Key keys[] = {
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY, XK_r, resetlayout, {0} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
diff --git a/dwm.c b/dwm.c
index 4465af1..77727ea 100644
--- a/dwm.c
+++ b/dwm.c
@@ -188,6 +188,7 @@ static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
+static void resetlayout(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
@@ -1265,6 +1266,16 @@ recttomon(int x, int y, int w, int h)
return r;
}
+void
+resetlayout(const Arg *arg)
+{
+ Arg default_layout = {.v = &layouts[0]};
+ Arg default_mfact = {.f = mfact + 1};
+
+ setlayout(&default_layout);
+ setmfact(&default_mfact);
+}
+
void
resize(Client *c, int x, int y, int w, int h, int interact)
{
@@ -1282,6 +1293,10 @@ resizeclient(Client *c, int x, int y, int w, int h)
c->oldw = c->w; c->w = wc.width = w;
c->oldh = c->h; c->h = wc.height = h;
wc.border_width = c->bw;
+
+ if ((nexttiled(c->mon->clients) == c) && !(nexttiled(c->next)))
+ resetlayout(NULL);
+
XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
configure(c);
XSync(dpy, False);
--
2.32.0

View File

@ -0,0 +1,36 @@
diff -r -u a/config.def.h b/config.def.h
--- a/config.def.h 2022-01-07 06:42:18.000000000 -0500
+++ b/config.def.h 2022-01-23 16:03:42.521951418 -0500
@@ -69,6 +69,7 @@
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
+ { MODKEY, XK_o, resetnmaster, {0} },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
diff -r -u a/dwm.c b/dwm.c
--- a/dwm.c 2022-01-23 16:06:01.221948285 -0500
+++ b/dwm.c 2022-01-23 16:05:35.949948855 -0500
@@ -191,6 +191,7 @@
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
static Monitor *recttomon(int x, int y, int w, int h);
+static void resetnmaster(const Arg *arg);
static void resize(Client *c, int x, int y, int w, int h, int interact);
static void resizeclient(Client *c, int x, int y, int w, int h);
static void resizemouse(const Arg *arg);
@@ -1296,6 +1297,13 @@
}
void
+resetnmaster(const Arg *arg)
+{
+ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = 1;
+ arrange(selmon);
+}
+
+void
resize(Client *c, int x, int y, int w, int h, int interact)
{
if (applysizehints(c, &x, &y, &w, &h, interact))

View File

@ -0,0 +1,114 @@
diff --git a/config.def.h b/config.def.h
index a2ac963..92a6a81 100644
--- a/config.def.h
+++ b/config.def.h
@@ -60,6 +60,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };
+#include "exitdwm.c"
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
@@ -94,7 +95,7 @@ static Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
- { MODKEY|ShiftMask, XK_q, quit, {0} },
+ { MODKEY|ShiftMask, XK_e, exitdwm, {0} },
};
/* button definitions */
diff --git a/exitdwm.c b/exitdwm.c
new file mode 100644
index 0000000..74c514f
--- /dev/null
+++ b/exitdwm.c
@@ -0,0 +1,87 @@
+# include <stdio.h>
+# include <string.h>
+
+void exitdwm ()
+{
+# if \
+ defined S_LOCK || \
+ defined S_RESTART_DWM || \
+ defined S_OFFSCREEN || \
+ defined S_EXIT || \
+ defined S_REBOOT || \
+ defined S_SHUTDOWN || \
+ defined S_LOCK_ICON || \
+ defined S_RESTART_DWM_ICON || \
+ defined S_OFFSCREEN_ICON || \
+ defined S_EXIT_ICON || \
+ defined S_REBOOT_ICON || \
+ defined S_SHUTDOWN_ICON || \
+ defined S_FORMAT || \
+ defined S_FORMAT_CLEAR
+# error (conflicting macro names)
+# endif
+
+# define S_LOCK "Lock"
+# define S_RESTART_DWM "restart Dwm"
+# define S_OFFSCREEN "Off-screen"
+# define S_EXIT "Exit"
+# define S_REBOOT "Reboot"
+# define S_SHUTDOWN "Shutdown"
+# define S_LOCK_ICON "\uf023" // <= FontAwesome icons
+# define S_RESTART_DWM_ICON "\uf01e"
+# define S_OFFSCREEN_ICON "\uf108"
+# define S_EXIT_ICON "\uf2f5"
+# define S_REBOOT_ICON "\uf021"
+# define S_SHUTDOWN_ICON "\uf011"
+
+# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION
+# define S_FORMAT_CLEAR "sed 's/^..//'"
+
+ FILE * exit_menu = popen (
+ "echo \""
+ S_FORMAT (LOCK) "\n"
+ S_FORMAT (RESTART_DWM) "\n"
+ S_FORMAT (OFFSCREEN) "\n"
+ S_FORMAT (EXIT) "\n"
+ S_FORMAT (REBOOT) "\n"
+ S_FORMAT (SHUTDOWN)
+ "\" | dmenu -p exit: | " S_FORMAT_CLEAR
+ ,
+ "r"
+ );
+
+ char exit_action [16];
+
+ if (
+ exit_menu == NULL ||
+ fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF
+ ) {
+ fputs ("Error. Failure in exit_dwm.", stderr);
+ goto close_streams;
+ }
+
+ if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep .5; xset dpms force off");
+ else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1});
+ else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off");
+ else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0});
+ else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot");
+ else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i");
+
+close_streams:
+ pclose (exit_menu);
+
+# undef S_LOCK
+# undef S_RESTART_DWM
+# undef S_OFFSCREEN
+# undef S_EXIT
+# undef S_REBOOT
+# undef S_SHUTDOWN
+# undef S_LOCK_ICON
+# undef S_RESTART_DWM_ICON
+# undef S_OFFSCREEN_ICON
+# undef S_EXIT_ICON
+# undef S_REBOOT_ICON
+# undef S_SHUTDOWN_ICON
+# undef S_FORMAT
+# undef S_FORMAT_CLEAR
+}

View File

@ -0,0 +1,84 @@
From 6b5e23cdf8108a9033acc7c21c8926c0c72647fc Mon Sep 17 00:00:00 2001
From: Adham Zahran <adhamzahranfms@gmail.com>
Date: Wed, 27 May 2020 18:07:57 +0200
Subject: [PATCH] Top bar now has buttons that launches programs
---
config.def.h | 8 ++++++++
dwm.c | 36 ++++++++++++++++++++++++++++++++++--
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..9231cd5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -21,6 +21,14 @@ static const char *colors[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+/* launcher commands (They must be NULL terminated) */
+static const char* surf[] = { "surf", "duckduckgo.com", NULL };
+
+static const Launcher launchers[] = {
+ /* command name to display */
+ { surf, "surf" },
+};
+
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
diff --git a/dwm.c b/dwm.c
index 9fd0286..79e7e20 100644
--- a/dwm.c
+++ b/dwm.c
@@ -141,6 +141,11 @@ typedef struct {
int monitor;
} Rule;
/* function declarations */
static void applyrules(Client *c);
static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact);
@@ -438,9 +443,26 @@ buttonpress(XEvent *e)
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
- } else if (ev->x < x + blw)
+ goto execute_handler;
+ } else if (ev->x < x + blw) {
click = ClkLtSymbol;
- else if (ev->x > selmon->ww - TEXTW(stext))
+ goto execute_handler;
+ }
+
+ if (ev->x > selmon->ww - TEXTW(stext))
click = ClkStatusText;
else
click = ClkWinTitle;
@@ -450,6 +472,9 @@ buttonpress(XEvent *e)
XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin;
}
+
+execute_handler:
+
for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state))
@@ -728,6 +753,13 @@ drawbar(Monitor *m)
w = blw = TEXTW(m->ltsymbol);
drw_setscheme(drw, scheme[SchemeNorm]);
x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0);
+
+ for (i = 0; i < LENGTH(launchers); i++)
+ {
+ w = TEXTW(launchers[i].name);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, urg & 1 << i);
+ x += w;
+ }
if ((w = m->ww - tw - x) > bh) {
if (m->sel) {
--
2.17.1

View File

@ -0,0 +1,95 @@
From 9a4037dc0ef56f91c009317e78e9e3790dafbb58 Mon Sep 17 00:00:00 2001
From: BrunoCooper17 <BrunoCooper17@outlook.com>
Date: Mon, 15 Nov 2021 14:04:53 -0600
Subject: [PATCH] MoveStack patch
This plugin allows you to move clients around in the stack and swap them
with the master. It emulates the behavior off mod+shift+j and mod+shift+k
in Xmonad. movestack(+1) will swap the client with the current focus with
the next client. movestack(-1) will swap the client with the current focus
with the previous client.
---
config.def.h | 3 +++
movestack.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
create mode 100644 movestack.c
diff --git a/config.def.h b/config.def.h
index a2ac963..33efa5b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -60,6 +60,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };
+#include "movestack.c"
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
@@ -71,6 +72,8 @@ static Key keys[] = {
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
+ { MODKEY|ShiftMask, XK_j, movestack, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_k, movestack, {.i = -1 } },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
diff --git a/movestack.c b/movestack.c
new file mode 100644
index 0000000..520f4ae
--- /dev/null
+++ b/movestack.c
@@ -0,0 +1,48 @@
+void
+movestack(const Arg *arg) {
+ Client *c = NULL, *p = NULL, *pc = NULL, *i;
+
+ if(arg->i > 0) {
+ /* find the client after selmon->sel */
+ for(c = selmon->sel->next; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+ if(!c)
+ for(c = selmon->clients; c && (!ISVISIBLE(c) || c->isfloating); c = c->next);
+
+ }
+ else {
+ /* find the client before selmon->sel */
+ for(i = selmon->clients; i != selmon->sel; i = i->next)
+ if(ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ if(!c)
+ for(; i; i = i->next)
+ if(ISVISIBLE(i) && !i->isfloating)
+ c = i;
+ }
+ /* find the client before selmon->sel and c */
+ for(i = selmon->clients; i && (!p || !pc); i = i->next) {
+ if(i->next == selmon->sel)
+ p = i;
+ if(i->next == c)
+ pc = i;
+ }
+
+ /* swap c and selmon->sel selmon->clients in the selmon->clients list */
+ if(c && c != selmon->sel) {
+ Client *temp = selmon->sel->next==c?selmon->sel:selmon->sel->next;
+ selmon->sel->next = c->next==selmon->sel?c:c->next;
+ c->next = temp;
+
+ if(p && p != c)
+ p->next = c;
+ if(pc && pc != selmon->sel)
+ pc->next = selmon->sel;
+
+ if(selmon->sel == selmon->clients)
+ selmon->clients = c;
+ else if(c == selmon->clients)
+ selmon->clients = selmon->sel;
+
+ arrange(selmon);
+ }
+}
\ No newline at end of file
--
2.33.1