Compare commits

...

No commits in common. "main" and "functionalgaps" have entirely different histories.

9 changed files with 5 additions and 413 deletions

1
.gitignore vendored
View File

@ -3,4 +3,3 @@
*.rej
dwm
config.h
.ccls-cache

View File

@ -4,7 +4,7 @@
/* appearance */
static unsigned int borderpx = 6; /* border pixel of windows */
static const int startwithgaps[] = { 1 }; /* 1 means gaps are used by default, this can be customized for each tag */
static const int startwithgaps[] = { 0 }; /* 1 means gaps are used by default, this can be customized for each tag */
static const unsigned int gappx[] = { 10 }; /* default gap between windows in pixels, this can be customized for each tag */
static unsigned int snap = 32; /* snap pixel */
static const int swallowfloating = 0; /* 1 means swallow floating windows by default */
@ -54,10 +54,6 @@ static Sp scratchpads[] = {
};
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char ptagf[] = "%s-%s"; /* format of a tag label */
static const char etagf[] = "%s"; /* format of an empty tag */
static const int lcaselbl = 0; /* 1 means make tag label lowercase */
static const Rule rules[] = {
/* class instance title tags mask isfloating isterminal noswallow monitor */
{ "St", NULL, NULL, 0, 0, 1, 0, -1 },
@ -81,7 +77,6 @@ static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "[M]", monocle },
{ "><>", NULL },
};
/* key definitions */
@ -121,31 +116,25 @@ ResourcePref resources[] = {
{ "mfact", FLOAT, &mfact },
};
#include "movestack.c"
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_r, spawn, {.v = dmenucmd } },
{ MODKEY, XK_w, spawn, {.v = dmenuwifi } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY|ShiftMask, XK_b, toggleborder, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_i, incnmaster, {.i = +1 } },
{ MODKEY|ShiftMask, 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|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },

3
dwm.1
View File

@ -116,9 +116,6 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
.B Mod1\-Shift\-c
Close focused window.
.TP
.B Mod1\-Shift\-f
Toggle fullscreen for focused window.
.TP
.B Mod1\-Shift\-space
Toggle focused window between tiled and floating state.
.TP

46
dwm.c
View File

@ -20,7 +20,6 @@
*
* To understand everything else, start reading main().
*/
#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
#include <errno.h>
#include <locale.h>
#include <signal.h>
@ -251,9 +250,7 @@ static void tagmon(const Arg *arg);
static Client *termforwin(const Client *c);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void toggleborder(const Arg *arg);
static void togglefloating(const Arg *arg);
static void togglefullscr(const Arg *arg);
static void togglescratch(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@ -340,8 +337,6 @@ struct Pertag {
int gappx[LENGTH(tags) + 1]; /* gaps for each tag */
};
unsigned int tagw[LENGTH(tags)];
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@ -558,7 +553,7 @@ buttonpress(XEvent *e)
/* Do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
x += tagw[i];
x += TEXTW(tags[i]);
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
@ -851,8 +846,6 @@ drawbar(Monitor *m)
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
char tagdisp[64];
char *masterclientontag[LENGTH(tags)];
if (!m->showbar)
return;
@ -864,35 +857,19 @@ drawbar(Monitor *m)
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
}
for (i = 0; i < LENGTH(tags); i++)
masterclientontag[i] = NULL;
for (c = m->clients; c; c = c->next) {
occ |= c->tags == TAGMASK ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
for (i = 0; i < LENGTH(tags); i++)
if (!masterclientontag[i] && c->tags & (1<<i)) {
XClassHint ch = { NULL, NULL };
XGetClassHint(dpy, c->win, &ch);
masterclientontag[i] = ch.res_class;
if (lcaselbl)
masterclientontag[i][0] = tolower(masterclientontag[i][0]);
}
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
/* Do not draw vacant tags */
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
if (masterclientontag[i])
snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]);
else
snprintf(tagdisp, 64, etagf, tags[i]);
masterclientontag[i] = tagdisp;
tagw[i] = w = TEXTW(masterclientontag[i]);
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeTagsSel : SchemeTagsNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
x += w;
}
w = TEXTW(m->ltsymbol);
@ -1301,8 +1278,7 @@ monocle(Monitor *m)
snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
for (c = nexttiled(m->clients); c; c = nexttiled(c->next))
if (selmon->pertag->drawwithgaps[selmon->pertag->curtag])
resize(c, m->wx + gappx[0], m->wy + gappx[0], m->ww - 2 * c->bw - gappx[0] * 2, m->wh - 2 * c->bw - gappx[0] * 2, 0);
// resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, 0);
else
resize(c, m->wx - c->bw, m->wy, m->ww, m->wh, False);
}
@ -2031,13 +2007,6 @@ togglebar(const Arg *arg)
arrange(selmon);
}
void
toggleborder(const Arg *arg)
{
selmon->sel->bw = (selmon->sel->bw == borderpx ? 0 : borderpx);
arrange(selmon);
}
void
togglefloating(const Arg *arg)
{
@ -2093,13 +2062,6 @@ togglescratch(const Arg *arg)
}
}
void
togglefullscr(const Arg *arg)
{
if(selmon->sel)
setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
}
void
toggletag(const Arg *arg)
{

View File

@ -1,48 +0,0 @@
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);
}
}

View File

@ -1,68 +0,0 @@
From eea13010ffc3983392857ee1e3804e3aa1064d7a Mon Sep 17 00:00:00 2001
From: Soenke Lambert <s.lambert@mittwald.de>
Date: Wed, 13 Oct 2021 18:21:09 +0200
Subject: [PATCH] Fullscreen current window with [Alt]+[Shift]+[f]
This actually fullscreens a window, instead of just hiding the statusbar
and applying the monocle layout.
---
config.def.h | 1 +
dwm.1 | 3 +++
dwm.c | 8 ++++++++
3 files changed, 12 insertions(+)
diff --git a/config.def.h b/config.def.h
index 1c0b587..8cd3204 100644
--- a/config.def.h
+++ b/config.def.h
@@ -78,6 +78,7 @@ static Key keys[] = {
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
+ { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
diff --git a/dwm.1 b/dwm.1
index 13b3729..a368d05 100644
--- a/dwm.1
+++ b/dwm.1
@@ -116,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).
.B Mod1\-Shift\-c
Close focused window.
.TP
+.B Mod1\-Shift\-f
+Toggle fullscreen for focused window.
+.TP
.B Mod1\-Shift\-space
Toggle focused window between tiled and floating state.
.TP
diff --git a/dwm.c b/dwm.c
index 4465af1..c1b899a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void togglefullscr(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -1719,6 +1720,13 @@ togglefloating(const Arg *arg)
arrange(selmon);
}
+void
+togglefullscr(const Arg *arg)
+{
+ if(selmon->sel)
+ setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
+}
+
void
toggletag(const Arg *arg)
{
--
2.30.2

View File

@ -1,95 +0,0 @@
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

View File

@ -1,91 +0,0 @@
diff -pu dwm.hide_vacant_tags/config.def.h dwm.programtags+hidewithvacanttags/config.def.h
--- dwm.hide_vacant_tags/config.def.h 2021-03-15 16:37:24.586622415 -0500
+++ dwm.programtags+hidewithvacanttags/config.def.h 2021-03-15 16:32:37.586956549 -0500
@@ -21,6 +21,10 @@ static const char *colors[][3] = {
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
+static const char ptagf[] = "[%s %s]"; /* format of a tag label */
+static const char etagf[] = "[%s]"; /* format of an empty tag */
+static const int lcaselbl = 0; /* 1 means make tag label lowercase */
+
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
diff -pu dwm.hide_vacant_tags/dwm.c dwm.programtags+hidewithvacanttags/dwm.c
--- dwm.hide_vacant_tags/dwm.c 2021-03-15 16:37:38.189939908 -0500
+++ dwm.programtags+hidewithvacanttags/dwm.c 2021-03-15 16:32:23.693639390 -0500
@@ -20,6 +20,7 @@
*
* To understand everything else, start reading main().
*/
+#include <ctype.h> /* for making tab label lowercase, very tiny standard library */
#include <errno.h>
#include <locale.h>
#include <signal.h>
@@ -272,6 +273,8 @@ static Window root, wmcheckwin;
/* configuration, allows nested code to access above variables */
#include "config.h"
+unsigned int tagw[LENGTH(tags)];
+
/* compile-time check if all tags fit into an unsigned int bit array. */
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
@@ -438,7 +441,7 @@ buttonpress(XEvent *e)
/* do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
- x += TEXTW(tags[i]);
+ x += tagw[i];
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
@@ -706,6 +709,8 @@ drawbar(Monitor *m)
int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0;
Client *c;
+ char tagdisp[64];
+ char *masterclientontag[LENGTH(tags)];
/* draw status first so it can be overdrawn by tags later */
if (m == selmon) { /* status is only drawn on selected monitor */
@@ -714,10 +719,21 @@ drawbar(Monitor *m)
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
}
+ for (i = 0; i < LENGTH(tags); i++)
+ masterclientontag[i] = NULL;
+
for (c = m->clients; c; c = c->next) {
occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
+ for (i = 0; i < LENGTH(tags); i++)
+ if (!masterclientontag[i] && c->tags & (1<<i)) {
+ XClassHint ch = { NULL, NULL };
+ XGetClassHint(dpy, c->win, &ch);
+ masterclientontag[i] = ch.res_class;
+ if (lcaselbl)
+ masterclientontag[i][0] = tolower(masterclientontag[i][0]);
+ }
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
@@ -725,9 +741,14 @@ drawbar(Monitor *m)
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
- w = TEXTW(tags[i]);
+ if (masterclientontag[i])
+ snprintf(tagdisp, 64, ptagf, tags[i], masterclientontag[i]);
+ else
+ snprintf(tagdisp, 64, etagf, tags[i]);
+ masterclientontag[i] = tagdisp;
+ tagw[i] = w = TEXTW(masterclientontag[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
+ drw_text(drw, x, 0, w, bh, lrpad / 2, masterclientontag[i], urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);

View File

@ -1,53 +0,0 @@
From ef85b0473590615fda4ba4b20a717e42c99e3f99 Mon Sep 17 00:00:00 2001
From: Stanisław Bitner <sbitner420@tutanota.com>
Date: Tue, 9 Aug 2022 23:17:47 +0200
Subject: [PATCH] toggleborder
This patch allows you to toggle client border. It works by setting the
border of the client to 0 or to borderpx defined in configuration file.
---
config.def.h | 1 +
dwm.c | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/config.def.h b/config.def.h
index a2ac963..60b811f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -65,6 +65,7 @@ static Key keys[] = {
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_b, togglebar, {0} },
+ { MODKEY|ShiftMask, XK_b, toggleborder, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
diff --git a/dwm.c b/dwm.c
index 967c9e8..91d00f6 100644
--- a/dwm.c
+++ b/dwm.c
@@ -211,6 +211,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
+static void toggleborder(const Arg *arg);
static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
@@ -1707,6 +1708,13 @@ togglebar(const Arg *arg)
arrange(selmon);
}
+void
+toggleborder(const Arg *arg)
+{
+ selmon->sel->bw = (selmon->sel->bw == borderpx ? 0 : borderpx);
+ arrange(selmon);
+}
+
void
togglefloating(const Arg *arg)
{
--
2.37.1