Compare commits
1 Commits
2d38a8d50d
...
statuscmd
Author | SHA1 | Date | |
---|---|---|---|
e42bd55e46 |
12
config.def.h
12
config.def.h
@ -2,12 +2,9 @@
|
|||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
static const unsigned int gappx = 5; /* gaps between windows */
|
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
static const int horizpadbar = 2; /* horizontal padding for statusbar */
|
|
||||||
static const int vertpadbar = 0; /* vertical padding for statusbar */
|
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "monospace:size=10" };
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
static const char col_gray1[] = "#222222";
|
static const char col_gray1[] = "#222222";
|
||||||
@ -58,6 +55,8 @@ static const Layout layouts[] = {
|
|||||||
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
#define STATUSBAR "dwmblocks"
|
||||||
|
|
||||||
/* commands */
|
/* commands */
|
||||||
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 };
|
||||||
@ -88,9 +87,6 @@ static const Key keys[] = {
|
|||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
@ -110,7 +106,9 @@ static const Button buttons[] = {
|
|||||||
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
{ ClkStatusText, 0, Button1, sigstatusbar, {.i = 1} },
|
||||||
|
{ ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} },
|
||||||
|
{ ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} },
|
||||||
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
10
dwm.1
10
dwm.1
@ -140,16 +140,6 @@ View all windows with any tag.
|
|||||||
.B Mod1\-Control\-[1..n]
|
.B Mod1\-Control\-[1..n]
|
||||||
Add/remove all windows with nth tag to/from the view.
|
Add/remove all windows with nth tag to/from the view.
|
||||||
.TP
|
.TP
|
||||||
.B Mod1\--
|
|
||||||
Decrease the gaps around windows.
|
|
||||||
.TP
|
|
||||||
.B Mod1\-=
|
|
||||||
Increase the gaps around windows.
|
|
||||||
.TP
|
|
||||||
.B Mod1\-Shift-=
|
|
||||||
Reset the gaps around windows to
|
|
||||||
.BR 0 .
|
|
||||||
.TP
|
|
||||||
.B Mod1\-Shift\-q
|
.B Mod1\-Shift\-q
|
||||||
Quit dwm.
|
Quit dwm.
|
||||||
.SS Mouse commands
|
.SS Mouse commands
|
||||||
|
141
dwm.c
141
dwm.c
@ -118,7 +118,6 @@ struct Monitor {
|
|||||||
int by; /* bar geometry */
|
int by; /* bar geometry */
|
||||||
int mx, my, mw, mh; /* screen size */
|
int mx, my, mw, mh; /* screen size */
|
||||||
int wx, wy, ww, wh; /* window area */
|
int wx, wy, ww, wh; /* window area */
|
||||||
int gappx; /* gaps between windows */
|
|
||||||
unsigned int seltags;
|
unsigned int seltags;
|
||||||
unsigned int sellt;
|
unsigned int sellt;
|
||||||
unsigned int tagset[2];
|
unsigned int tagset[2];
|
||||||
@ -172,6 +171,7 @@ static void focusstack(const Arg *arg);
|
|||||||
static Atom getatomprop(Client *c, Atom prop);
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
static int getrootptr(int *x, int *y);
|
static int getrootptr(int *x, int *y);
|
||||||
static long getstate(Window w);
|
static long getstate(Window w);
|
||||||
|
static pid_t getstatusbarpid();
|
||||||
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
static void grabbuttons(Client *c, int focused);
|
static void grabbuttons(Client *c, int focused);
|
||||||
static void grabkeys(void);
|
static void grabkeys(void);
|
||||||
@ -200,12 +200,12 @@ static void sendmon(Client *c, Monitor *m);
|
|||||||
static void setclientstate(Client *c, long state);
|
static void setclientstate(Client *c, long state);
|
||||||
static void setfocus(Client *c);
|
static void setfocus(Client *c);
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
static void setfullscreen(Client *c, int fullscreen);
|
||||||
static void setgaps(const Arg *arg);
|
|
||||||
static void setlayout(const Arg *arg);
|
static void setlayout(const Arg *arg);
|
||||||
static void setmfact(const Arg *arg);
|
static void setmfact(const Arg *arg);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
static void seturgent(Client *c, int urg);
|
static void seturgent(Client *c, int urg);
|
||||||
static void showhide(Client *c);
|
static void showhide(Client *c);
|
||||||
|
static void sigstatusbar(const Arg *arg);
|
||||||
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);
|
||||||
@ -238,6 +238,9 @@ static void zoom(const Arg *arg);
|
|||||||
/* variables */
|
/* variables */
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
static char stext[256];
|
static char stext[256];
|
||||||
|
static int statusw;
|
||||||
|
static int statussig;
|
||||||
|
static pid_t statuspid = -1;
|
||||||
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 */
|
||||||
static int bh; /* bar height */
|
static int bh; /* bar height */
|
||||||
@ -424,6 +427,7 @@ buttonpress(XEvent *e)
|
|||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
XButtonPressedEvent *ev = &e->xbutton;
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
char *text, *s, ch;
|
||||||
|
|
||||||
click = ClkRootWin;
|
click = ClkRootWin;
|
||||||
/* focus monitor if necessary */
|
/* focus monitor if necessary */
|
||||||
@ -442,9 +446,27 @@ buttonpress(XEvent *e)
|
|||||||
arg.ui = 1 << i;
|
arg.ui = 1 << i;
|
||||||
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||||
click = ClkLtSymbol;
|
click = ClkLtSymbol;
|
||||||
else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
else if (ev->x > selmon->ww - statusw) {
|
||||||
|
x = selmon->ww - statusw;
|
||||||
click = ClkStatusText;
|
click = ClkStatusText;
|
||||||
else
|
statussig = 0;
|
||||||
|
for (text = s = stext; *s && x <= ev->x; s++) {
|
||||||
|
if ((unsigned char)(*s) < ' ') {
|
||||||
|
ch = *s;
|
||||||
|
*s = '\0';
|
||||||
|
x += TEXTW(text) - lrpad;
|
||||||
|
*s = ch;
|
||||||
|
text = s + 1;
|
||||||
|
if (x >= ev->x)
|
||||||
|
break;
|
||||||
|
/* reset on matching signal raw byte */
|
||||||
|
if (ch == statussig)
|
||||||
|
statussig = 0;
|
||||||
|
else
|
||||||
|
statussig = ch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
click = ClkWinTitle;
|
click = ClkWinTitle;
|
||||||
} else if ((c = wintoclient(ev->window))) {
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
focus(c);
|
focus(c);
|
||||||
@ -642,7 +664,6 @@ createmon(void)
|
|||||||
m->nmaster = nmaster;
|
m->nmaster = nmaster;
|
||||||
m->showbar = showbar;
|
m->showbar = showbar;
|
||||||
m->topbar = topbar;
|
m->topbar = topbar;
|
||||||
m->gappx = gappx;
|
|
||||||
m->lt[0] = &layouts[0];
|
m->lt[0] = &layouts[0];
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
||||||
@ -711,9 +732,24 @@ drawbar(Monitor *m)
|
|||||||
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
|
char *text, *s, ch;
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
tw = TEXTW(stext);
|
|
||||||
drw_text(drw, m->ww - tw, 0, tw, bh, lrpad / 2, stext, 0);
|
x = 0;
|
||||||
|
for (text = s = stext; *s; s++) {
|
||||||
|
if ((unsigned char)(*s) < ' ') {
|
||||||
|
ch = *s;
|
||||||
|
*s = '\0';
|
||||||
|
tw = TEXTW(text) - lrpad;
|
||||||
|
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||||
|
x += tw;
|
||||||
|
*s = ch;
|
||||||
|
text = s + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tw = TEXTW(text) - lrpad + 2;
|
||||||
|
drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||||
|
tw = statusw;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
for (c = m->clients; c; c = c->next) {
|
||||||
@ -879,6 +915,30 @@ getatomprop(Client *c, Atom prop)
|
|||||||
return atom;
|
return atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pid_t
|
||||||
|
getstatusbarpid()
|
||||||
|
{
|
||||||
|
char buf[32], *str = buf, *c;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if (statuspid > 0) {
|
||||||
|
snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||||
|
if ((fp = fopen(buf, "r"))) {
|
||||||
|
fgets(buf, sizeof(buf), fp);
|
||||||
|
while ((c = strchr(str, '/')))
|
||||||
|
str = c + 1;
|
||||||
|
fclose(fp);
|
||||||
|
if (!strcmp(str, STATUSBAR))
|
||||||
|
return statuspid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!(fp = popen("pidof -s "STATUSBAR, "r")))
|
||||||
|
return -1;
|
||||||
|
fgets(buf, sizeof(buf), fp);
|
||||||
|
pclose(fp);
|
||||||
|
return strtol(buf, NULL, 10);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
getrootptr(int *x, int *y)
|
getrootptr(int *x, int *y)
|
||||||
{
|
{
|
||||||
@ -1509,16 +1569,6 @@ setfullscreen(Client *c, int fullscreen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
setgaps(const Arg *arg)
|
|
||||||
{
|
|
||||||
if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
|
|
||||||
selmon->gappx = 0;
|
|
||||||
else
|
|
||||||
selmon->gappx += arg->i;
|
|
||||||
arrange(selmon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
setlayout(const Arg *arg)
|
setlayout(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -1573,8 +1623,8 @@ setup(void)
|
|||||||
drw = drw_create(dpy, screen, root, sw, sh);
|
drw = drw_create(dpy, screen, root, sw, sh);
|
||||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
die("no fonts could be loaded.");
|
die("no fonts could be loaded.");
|
||||||
lrpad = drw->fonts->h + horizpadbar;
|
lrpad = drw->fonts->h;
|
||||||
bh = drw->fonts->h + vertpadbar;
|
bh = drw->fonts->h + 2;
|
||||||
updategeom();
|
updategeom();
|
||||||
/* init atoms */
|
/* init atoms */
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
@ -1656,6 +1706,20 @@ showhide(Client *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigstatusbar(const Arg *arg)
|
||||||
|
{
|
||||||
|
union sigval sv;
|
||||||
|
|
||||||
|
if (!statussig)
|
||||||
|
return;
|
||||||
|
sv.sival_int = arg->i;
|
||||||
|
if ((statuspid = getstatusbarpid()) <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -1709,18 +1773,18 @@ tile(Monitor *m)
|
|||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww - m->gappx;
|
mw = m->ww;
|
||||||
for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
||||||
if (i < m->nmaster) {
|
if (i < m->nmaster) {
|
||||||
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
if (my + HEIGHT(c) + m->gappx < m->wh)
|
if (my + HEIGHT(c) < m->wh)
|
||||||
my += HEIGHT(c) + m->gappx;
|
my += HEIGHT(c);
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i) - m->gappx;
|
h = (m->wh - ty) / (n - i);
|
||||||
resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
|
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
if (ty + HEIGHT(c) + m->gappx < m->wh)
|
if (ty + HEIGHT(c) < m->wh)
|
||||||
ty += HEIGHT(c) + m->gappx;
|
ty += HEIGHT(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2017,8 +2081,25 @@ updatesizehints(Client *c)
|
|||||||
void
|
void
|
||||||
updatestatus(void)
|
updatestatus(void)
|
||||||
{
|
{
|
||||||
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
||||||
strcpy(stext, "dwm-"VERSION);
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
statusw = TEXTW(stext) - lrpad + 2;
|
||||||
|
} else {
|
||||||
|
char *text, *s, ch;
|
||||||
|
|
||||||
|
statusw = 0;
|
||||||
|
for (text = s = stext; *s; s++) {
|
||||||
|
if ((unsigned char)(*s) < ' ') {
|
||||||
|
ch = *s;
|
||||||
|
*s = '\0';
|
||||||
|
statusw += TEXTW(text) - lrpad;
|
||||||
|
*s = ch;
|
||||||
|
text = s + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statusw += TEXTW(text) - lrpad + 2;
|
||||||
|
|
||||||
|
}
|
||||||
drawbar(selmon);
|
drawbar(selmon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,138 +0,0 @@
|
|||||||
From 7b7773458c072e4b24d6ea32d0364a8e402e4a43 Mon Sep 17 00:00:00 2001
|
|
||||||
From: swy7ch <swy7ch@protonmail.com>
|
|
||||||
Date: Fri, 8 May 2020 19:07:24 +0200
|
|
||||||
Subject: [PATCH] [PATCH] update dwm-fullgaps patch to be used with tile layout
|
|
||||||
update
|
|
||||||
|
|
||||||
the recent tile layout changes in commit HEAD~1 (f09418b) broke the
|
|
||||||
patch
|
|
||||||
|
|
||||||
this patch adapt the new `if` statements to take gaps into account
|
|
||||||
|
|
||||||
this patch also provides manpage entries for the keybindings
|
|
||||||
---
|
|
||||||
config.def.h | 4 ++++
|
|
||||||
dwm.1 | 10 ++++++++++
|
|
||||||
dwm.c | 33 +++++++++++++++++++++++----------
|
|
||||||
3 files changed, 37 insertions(+), 10 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index 1c0b587..38d2f6c 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -2,6 +2,7 @@
|
|
||||||
|
|
||||||
/* appearance */
|
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
|
||||||
+static const unsigned int gappx = 5; /* gaps between windows */
|
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
|
||||||
@@ -84,6 +85,9 @@ static Key keys[] = {
|
|
||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
|
||||||
+ { MODKEY, XK_minus, setgaps, {.i = -1 } },
|
|
||||||
+ { MODKEY, XK_equal, setgaps, {.i = +1 } },
|
|
||||||
+ { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
|
||||||
TAGKEYS( XK_1, 0)
|
|
||||||
TAGKEYS( XK_2, 1)
|
|
||||||
TAGKEYS( XK_3, 2)
|
|
||||||
diff --git a/dwm.1 b/dwm.1
|
|
||||||
index 13b3729..0202d96 100644
|
|
||||||
--- a/dwm.1
|
|
||||||
+++ b/dwm.1
|
|
||||||
@@ -140,6 +140,16 @@ View all windows with any tag.
|
|
||||||
.B Mod1\-Control\-[1..n]
|
|
||||||
Add/remove all windows with nth tag to/from the view.
|
|
||||||
.TP
|
|
||||||
+.B Mod1\--
|
|
||||||
+Decrease the gaps around windows.
|
|
||||||
+.TP
|
|
||||||
+.B Mod1\-=
|
|
||||||
+Increase the gaps around windows.
|
|
||||||
+.TP
|
|
||||||
+.B Mod1\-Shift-=
|
|
||||||
+Reset the gaps around windows to
|
|
||||||
+.BR 0 .
|
|
||||||
+.TP
|
|
||||||
.B Mod1\-Shift\-q
|
|
||||||
Quit dwm.
|
|
||||||
.SS Mouse commands
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index 9fd0286..45a58f3 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -119,6 +119,7 @@ struct Monitor {
|
|
||||||
int by; /* bar geometry */
|
|
||||||
int mx, my, mw, mh; /* screen size */
|
|
||||||
int wx, wy, ww, wh; /* window area */
|
|
||||||
+ int gappx; /* gaps between windows */
|
|
||||||
unsigned int seltags;
|
|
||||||
unsigned int sellt;
|
|
||||||
unsigned int tagset[2];
|
|
||||||
@@ -200,6 +201,7 @@ static void sendmon(Client *c, Monitor *m);
|
|
||||||
static void setclientstate(Client *c, long state);
|
|
||||||
static void setfocus(Client *c);
|
|
||||||
static void setfullscreen(Client *c, int fullscreen);
|
|
||||||
+static void setgaps(const Arg *arg);
|
|
||||||
static void setlayout(const Arg *arg);
|
|
||||||
static void setmfact(const Arg *arg);
|
|
||||||
static void setup(void);
|
|
||||||
@@ -639,6 +641,7 @@ createmon(void)
|
|
||||||
m->nmaster = nmaster;
|
|
||||||
m->showbar = showbar;
|
|
||||||
m->topbar = topbar;
|
|
||||||
+ m->gappx = gappx;
|
|
||||||
m->lt[0] = &layouts[0];
|
|
||||||
m->lt[1] = &layouts[1 % LENGTH(layouts)];
|
|
||||||
strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol);
|
|
||||||
@@ -1498,6 +1501,16 @@ setfullscreen(Client *c, int fullscreen)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+void
|
|
||||||
+setgaps(const Arg *arg)
|
|
||||||
+{
|
|
||||||
+ if ((arg->i == 0) || (selmon->gappx + arg->i < 0))
|
|
||||||
+ selmon->gappx = 0;
|
|
||||||
+ else
|
|
||||||
+ selmon->gappx += arg->i;
|
|
||||||
+ arrange(selmon);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
void
|
|
||||||
setlayout(const Arg *arg)
|
|
||||||
{
|
|
||||||
@@ -1684,18 +1697,18 @@ tile(Monitor *m)
|
|
||||||
if (n > m->nmaster)
|
|
||||||
mw = m->nmaster ? m->ww * m->mfact : 0;
|
|
||||||
else
|
|
||||||
- mw = m->ww;
|
|
||||||
- for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
+ mw = m->ww - m->gappx;
|
|
||||||
+ for (i = 0, my = ty = m->gappx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
|
||||||
if (i < m->nmaster) {
|
|
||||||
- h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
|
||||||
- resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
|
||||||
- if (my + HEIGHT(c) < m->wh)
|
|
||||||
- my += HEIGHT(c);
|
|
||||||
+ h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
|
||||||
+ resize(c, m->wx + m->gappx, m->wy + my, mw - (2*c->bw) - m->gappx, h - (2*c->bw), 0);
|
|
||||||
+ if (my + HEIGHT(c) + m->gappx < m->wh)
|
|
||||||
+ my += HEIGHT(c) + m->gappx;
|
|
||||||
} else {
|
|
||||||
- h = (m->wh - ty) / (n - i);
|
|
||||||
- resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
|
||||||
- if (ty + HEIGHT(c) < m->wh)
|
|
||||||
- ty += HEIGHT(c);
|
|
||||||
+ h = (m->wh - ty) / (n - i) - m->gappx;
|
|
||||||
+ resize(c, m->wx + mw + m->gappx, m->wy + ty, m->ww - mw - (2*c->bw) - 2*m->gappx, h - (2*c->bw), 0);
|
|
||||||
+ if (ty + HEIGHT(c) + m->gappx < m->wh)
|
|
||||||
+ ty += HEIGHT(c) + m->gappx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.26.2
|
|
||||||
|
|
220
patches/dwm-statuscmd-20241009-8933ebc.diff
Normal file
220
patches/dwm-statuscmd-20241009-8933ebc.diff
Normal file
@ -0,0 +1,220 @@
|
|||||||
|
From ca2a2e6386a746ebfc3480787e5d99da11e7abee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Justinas Grigas <dev@jstnas.com>
|
||||||
|
Date: Wed, 9 Oct 2024 01:00:20 +0100
|
||||||
|
Subject: [PATCH] [dwm][statuscmd] better click regions
|
||||||
|
|
||||||
|
The main improvement of this patch over the previous version 20210405 is that
|
||||||
|
the click region now ends on a matching signal raw byte.
|
||||||
|
|
||||||
|
The matching byte is optional, and without it dwm will behave as before.
|
||||||
|
|
||||||
|
To take advantage of this feature, scripts need to be modified to print the raw
|
||||||
|
byte at the end as well.
|
||||||
|
|
||||||
|
In addition, this patch cleanly applies onto master branch.
|
||||||
|
---
|
||||||
|
config.def.h | 6 ++-
|
||||||
|
dwm.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++---
|
||||||
|
2 files changed, 104 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 9efa774..d008275 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -55,6 +55,8 @@ static const Layout layouts[] = {
|
||||||
|
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
|
||||||
|
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
|
||||||
|
|
||||||
|
+#define STATUSBAR "dwmblocks"
|
||||||
|
+
|
||||||
|
/* commands */
|
||||||
|
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 };
|
||||||
|
@@ -104,7 +106,9 @@ static const Button buttons[] = {
|
||||||
|
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
|
||||||
|
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
|
||||||
|
{ ClkWinTitle, 0, Button2, zoom, {0} },
|
||||||
|
- { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
|
||||||
|
+ { ClkStatusText, 0, Button1, sigstatusbar, {.i = 1} },
|
||||||
|
+ { ClkStatusText, 0, Button2, sigstatusbar, {.i = 2} },
|
||||||
|
+ { ClkStatusText, 0, Button3, sigstatusbar, {.i = 3} },
|
||||||
|
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
|
||||||
|
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 1443802..94ee0c7 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -171,6 +171,7 @@ static void focusstack(const Arg *arg);
|
||||||
|
static Atom getatomprop(Client *c, Atom prop);
|
||||||
|
static int getrootptr(int *x, int *y);
|
||||||
|
static long getstate(Window w);
|
||||||
|
+static pid_t getstatusbarpid();
|
||||||
|
static int gettextprop(Window w, Atom atom, char *text, unsigned int size);
|
||||||
|
static void grabbuttons(Client *c, int focused);
|
||||||
|
static void grabkeys(void);
|
||||||
|
@@ -204,6 +205,7 @@ static void setmfact(const Arg *arg);
|
||||||
|
static void setup(void);
|
||||||
|
static void seturgent(Client *c, int urg);
|
||||||
|
static void showhide(Client *c);
|
||||||
|
+static void sigstatusbar(const Arg *arg);
|
||||||
|
static void spawn(const Arg *arg);
|
||||||
|
static void tag(const Arg *arg);
|
||||||
|
static void tagmon(const Arg *arg);
|
||||||
|
@@ -236,6 +238,9 @@ static void zoom(const Arg *arg);
|
||||||
|
/* variables */
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
static char stext[256];
|
||||||
|
+static int statusw;
|
||||||
|
+static int statussig;
|
||||||
|
+static pid_t statuspid = -1;
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
static int bh; /* bar height */
|
||||||
|
@@ -422,6 +427,7 @@ buttonpress(XEvent *e)
|
||||||
|
Client *c;
|
||||||
|
Monitor *m;
|
||||||
|
XButtonPressedEvent *ev = &e->xbutton;
|
||||||
|
+ char *text, *s, ch;
|
||||||
|
|
||||||
|
click = ClkRootWin;
|
||||||
|
/* focus monitor if necessary */
|
||||||
|
@@ -440,9 +446,27 @@ buttonpress(XEvent *e)
|
||||||
|
arg.ui = 1 << i;
|
||||||
|
} else if (ev->x < x + TEXTW(selmon->ltsymbol))
|
||||||
|
click = ClkLtSymbol;
|
||||||
|
- else if (ev->x > selmon->ww - (int)TEXTW(stext))
|
||||||
|
+ else if (ev->x > selmon->ww - statusw) {
|
||||||
|
+ x = selmon->ww - statusw;
|
||||||
|
click = ClkStatusText;
|
||||||
|
- else
|
||||||
|
+ statussig = 0;
|
||||||
|
+ for (text = s = stext; *s && x <= ev->x; s++) {
|
||||||
|
+ if ((unsigned char)(*s) < ' ') {
|
||||||
|
+ ch = *s;
|
||||||
|
+ *s = '\0';
|
||||||
|
+ x += TEXTW(text) - lrpad;
|
||||||
|
+ *s = ch;
|
||||||
|
+ text = s + 1;
|
||||||
|
+ if (x >= ev->x)
|
||||||
|
+ break;
|
||||||
|
+ /* reset on matching signal raw byte */
|
||||||
|
+ if (ch == statussig)
|
||||||
|
+ statussig = 0;
|
||||||
|
+ else
|
||||||
|
+ statussig = ch;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ } else
|
||||||
|
click = ClkWinTitle;
|
||||||
|
} else if ((c = wintoclient(ev->window))) {
|
||||||
|
focus(c);
|
||||||
|
@@ -708,9 +732,24 @@ drawbar(Monitor *m)
|
||||||
|
|
||||||
|
/* draw status first so it can be overdrawn by tags later */
|
||||||
|
if (m == selmon) { /* status is only drawn on selected monitor */
|
||||||
|
+ char *text, *s, ch;
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
||||||
|
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
||||||
|
+
|
||||||
|
+ x = 0;
|
||||||
|
+ for (text = s = stext; *s; s++) {
|
||||||
|
+ if ((unsigned char)(*s) < ' ') {
|
||||||
|
+ ch = *s;
|
||||||
|
+ *s = '\0';
|
||||||
|
+ tw = TEXTW(text) - lrpad;
|
||||||
|
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||||
|
+ x += tw;
|
||||||
|
+ *s = ch;
|
||||||
|
+ text = s + 1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ tw = TEXTW(text) - lrpad + 2;
|
||||||
|
+ drw_text(drw, m->ww - statusw + x, 0, tw, bh, 0, text, 0);
|
||||||
|
+ tw = statusw;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = m->clients; c; c = c->next) {
|
||||||
|
@@ -876,6 +915,30 @@ getatomprop(Client *c, Atom prop)
|
||||||
|
return atom;
|
||||||
|
}
|
||||||
|
|
||||||
|
+pid_t
|
||||||
|
+getstatusbarpid()
|
||||||
|
+{
|
||||||
|
+ char buf[32], *str = buf, *c;
|
||||||
|
+ FILE *fp;
|
||||||
|
+
|
||||||
|
+ if (statuspid > 0) {
|
||||||
|
+ snprintf(buf, sizeof(buf), "/proc/%u/cmdline", statuspid);
|
||||||
|
+ if ((fp = fopen(buf, "r"))) {
|
||||||
|
+ fgets(buf, sizeof(buf), fp);
|
||||||
|
+ while ((c = strchr(str, '/')))
|
||||||
|
+ str = c + 1;
|
||||||
|
+ fclose(fp);
|
||||||
|
+ if (!strcmp(str, STATUSBAR))
|
||||||
|
+ return statuspid;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ if (!(fp = popen("pidof -s "STATUSBAR, "r")))
|
||||||
|
+ return -1;
|
||||||
|
+ fgets(buf, sizeof(buf), fp);
|
||||||
|
+ pclose(fp);
|
||||||
|
+ return strtol(buf, NULL, 10);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int
|
||||||
|
getrootptr(int *x, int *y)
|
||||||
|
{
|
||||||
|
@@ -1643,6 +1706,20 @@ showhide(Client *c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+sigstatusbar(const Arg *arg)
|
||||||
|
+{
|
||||||
|
+ union sigval sv;
|
||||||
|
+
|
||||||
|
+ if (!statussig)
|
||||||
|
+ return;
|
||||||
|
+ sv.sival_int = arg->i;
|
||||||
|
+ if ((statuspid = getstatusbarpid()) <= 0)
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ sigqueue(statuspid, SIGRTMIN+statussig, sv);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
spawn(const Arg *arg)
|
||||||
|
{
|
||||||
|
@@ -2004,8 +2081,25 @@ updatesizehints(Client *c)
|
||||||
|
void
|
||||||
|
updatestatus(void)
|
||||||
|
{
|
||||||
|
- if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext)))
|
||||||
|
+ if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) {
|
||||||
|
strcpy(stext, "dwm-"VERSION);
|
||||||
|
+ statusw = TEXTW(stext) - lrpad + 2;
|
||||||
|
+ } else {
|
||||||
|
+ char *text, *s, ch;
|
||||||
|
+
|
||||||
|
+ statusw = 0;
|
||||||
|
+ for (text = s = stext; *s; s++) {
|
||||||
|
+ if ((unsigned char)(*s) < ' ') {
|
||||||
|
+ ch = *s;
|
||||||
|
+ *s = '\0';
|
||||||
|
+ statusw += TEXTW(text) - lrpad;
|
||||||
|
+ *s = ch;
|
||||||
|
+ text = s + 1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ statusw += TEXTW(text) - lrpad + 2;
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
drawbar(selmon);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.46.2
|
||||||
|
|
@ -1,62 +0,0 @@
|
|||||||
From d6dd69c26f4272f87672ae54f69dc0d48650d34b Mon Sep 17 00:00:00 2001
|
|
||||||
From: taep96 <64481039+taep96@users.noreply.github.com>
|
|
||||||
Date: Mon, 7 Feb 2022 19:09:45 +0100
|
|
||||||
Subject: [PATCH] Fixed | Replaces magic numbers in statusbar with configurable
|
|
||||||
variables.
|
|
||||||
|
|
||||||
horizpadbar for horizontal statusbar padding
|
|
||||||
vertpadbar for vertical statusbar padding
|
|
||||||
|
|
||||||
StatusText now has both left and right padding,
|
|
||||||
as well as the vertical padding that all of the statusbar shares.
|
|
||||||
|
|
||||||
Other than the addition of left padding to StatusText, appearance
|
|
||||||
of the statusbar is identical to pre-patch when using the defaults
|
|
||||||
in config.def.h
|
|
||||||
---
|
|
||||||
config.def.h | 2 ++
|
|
||||||
dwm.c | 8 ++++----
|
|
||||||
2 files changed, 6 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/config.def.h b/config.def.h
|
|
||||||
index a2ac963..6cb845c 100644
|
|
||||||
--- a/config.def.h
|
|
||||||
+++ b/config.def.h
|
|
||||||
@@ -5,6 +5,8 @@ static const unsigned int borderpx = 1; /* border pixel of windows */
|
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
|
||||||
+static const int horizpadbar = 2; /* horizontal padding for statusbar */
|
|
||||||
+static const int vertpadbar = 0; /* vertical padding for statusbar */
|
|
||||||
static const char *fonts[] = { "monospace:size=10" };
|
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
|
||||||
static const char col_gray1[] = "#222222";
|
|
||||||
diff --git a/dwm.c b/dwm.c
|
|
||||||
index a96f33c..a1b8c95 100644
|
|
||||||
--- a/dwm.c
|
|
||||||
+++ b/dwm.c
|
|
||||||
@@ -708,8 +708,8 @@ drawbar(Monitor *m)
|
|
||||||
/* draw status first so it can be overdrawn by tags later */
|
|
||||||
if (m == selmon) { /* status is only drawn on selected monitor */
|
|
||||||
drw_setscheme(drw, scheme[SchemeNorm]);
|
|
||||||
- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
|
|
||||||
- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0);
|
|
||||||
+ tw = TEXTW(stext);
|
|
||||||
+ drw_text(drw, m->ww - tw, 0, tw, bh, lrpad / 2, stext, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (c = m->clients; c; c = c->next) {
|
|
||||||
@@ -1548,8 +1548,8 @@ setup(void)
|
|
||||||
drw = drw_create(dpy, screen, root, sw, sh);
|
|
||||||
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
|
||||||
die("no fonts could be loaded.");
|
|
||||||
- lrpad = drw->fonts->h;
|
|
||||||
- bh = drw->fonts->h + 2;
|
|
||||||
+ lrpad = drw->fonts->h + horizpadbar;
|
|
||||||
+ bh = drw->fonts->h + vertpadbar;
|
|
||||||
updategeom();
|
|
||||||
/* init atoms */
|
|
||||||
utf8string = XInternAtom(dpy, "UTF8_STRING", False);
|
|
||||||
--
|
|
||||||
2.35.1
|
|
||||||
|
|
Reference in New Issue
Block a user