Compare commits
16 Commits
6.5
...
24537d73d0
| Author | SHA1 | Date | |
|---|---|---|---|
| 24537d73d0 | |||
| e5db8641d0 | |||
| 788951755b | |||
| 09fb3c5a20 | |||
| 6c8df4b872 | |||
| a99f4630c4 | |||
| c3f2c75d8a | |||
| 56a140cadf | |||
|
|
7c3abae4e6 | ||
|
|
93f26863d1 | ||
|
|
74edc27caa | ||
|
|
693d94d350 | ||
|
|
cfb8627a80 | ||
|
|
fcb2476b69 | ||
|
|
8933ebcf50 | ||
|
|
5687f46964 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.o
|
||||||
|
config.h
|
||||||
27
config.def.h
27
config.def.h
@@ -1,17 +1,23 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 1; /* border pixel of windows */
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
|
static const unsigned int gappx = 6; /* 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 char *fonts[] = { "monospace:size=10" };
|
static const char *fonts[] = { "JetBrainsMono Nerd Font:size=14" };
|
||||||
static const char dmenufont[] = "monospace:size=10";
|
static const char dmenufont[] = "monospace:size=10";
|
||||||
static const char col_gray1[] = "#222222";
|
// background colour
|
||||||
|
static const char col_gray1[] = "#440E50";
|
||||||
|
// inactive window border colour
|
||||||
static const char col_gray2[] = "#444444";
|
static const char col_gray2[] = "#444444";
|
||||||
|
// font colour
|
||||||
static const char col_gray3[] = "#bbbbbb";
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
// current tag and current window font colour
|
||||||
static const char col_gray4[] = "#eeeeee";
|
static const char col_gray4[] = "#eeeeee";
|
||||||
static const char col_cyan[] = "#005577";
|
// Top bar second colour and active window border colour
|
||||||
|
static const char col_cyan[] = "#1F0B4B";
|
||||||
static const char *colors[][3] = {
|
static const char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
@@ -36,6 +42,7 @@ static const float mfact = 0.55; /* factor of master area size [0.05..0.95]
|
|||||||
static const int nmaster = 1; /* number of clients in master area */
|
static const int nmaster = 1; /* number of clients in master area */
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
||||||
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */
|
||||||
|
static const int refreshrate = 120; /* refresh rate (per second) for client move/resize */
|
||||||
|
|
||||||
static const Layout layouts[] = {
|
static const Layout layouts[] = {
|
||||||
/* symbol arrange function */
|
/* symbol arrange function */
|
||||||
@@ -45,7 +52,7 @@ static const Layout layouts[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
#define MODKEY Mod1Mask
|
#define MODKEY Mod4Mask
|
||||||
#define TAGKEYS(KEY,TAG) \
|
#define TAGKEYS(KEY,TAG) \
|
||||||
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
|
||||||
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
|
||||||
@@ -58,13 +65,18 @@ static const Layout layouts[] = {
|
|||||||
/* 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 };
|
||||||
|
static const char *rofi[] = {"rofi", "-show", "drun", "-show-emojis", NULL};
|
||||||
|
static const char *browser[] = {"brave"};
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
|
static const char *alatty[] = {"alacritty", NULL};
|
||||||
|
|
||||||
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 = rofi } },
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
|
{ MODKEY|ControlMask, XK_Return, spawn, {.v = alatty } },
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
|
{ MODKEY|ShiftMask, XK_b, spawn, {.v = browser } },
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
@@ -85,6 +97,9 @@ 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)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.5
|
VERSION = 6.6
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
|||||||
145
drw.c
145
drw.c
@@ -9,54 +9,40 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define UTF_INVALID 0xFFFD
|
#define UTF_INVALID 0xFFFD
|
||||||
#define UTF_SIZ 4
|
|
||||||
|
|
||||||
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
static int
|
||||||
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
utf8decode(const char *s_in, long *u, int *err)
|
||||||
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
|
||||||
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
|
||||||
|
|
||||||
static long
|
|
||||||
utf8decodebyte(const char c, size_t *i)
|
|
||||||
{
|
{
|
||||||
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
static const unsigned char lens[] = {
|
||||||
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
/* 0XXXX */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||||
return (unsigned char)c & ~utfmask[*i];
|
/* 10XXX */ 0, 0, 0, 0, 0, 0, 0, 0, /* invalid */
|
||||||
return 0;
|
/* 110XX */ 2, 2, 2, 2,
|
||||||
}
|
/* 1110X */ 3, 3,
|
||||||
|
/* 11110 */ 4,
|
||||||
static size_t
|
/* 11111 */ 0, /* invalid */
|
||||||
utf8validate(long *u, size_t i)
|
};
|
||||||
{
|
static const unsigned char leading_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
||||||
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
static const unsigned int overlong[] = { 0x0, 0x80, 0x0800, 0x10000 };
|
||||||
*u = UTF_INVALID;
|
|
||||||
for (i = 1; *u > utfmax[i]; ++i)
|
|
||||||
;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t
|
|
||||||
utf8decode(const char *c, long *u, size_t clen)
|
|
||||||
{
|
|
||||||
size_t i, j, len, type;
|
|
||||||
long udecoded;
|
|
||||||
|
|
||||||
|
const unsigned char *s = (const unsigned char *)s_in;
|
||||||
|
int len = lens[*s >> 3];
|
||||||
*u = UTF_INVALID;
|
*u = UTF_INVALID;
|
||||||
if (!clen)
|
*err = 1;
|
||||||
return 0;
|
if (len == 0)
|
||||||
udecoded = utf8decodebyte(c[0], &len);
|
|
||||||
if (!BETWEEN(len, 1, UTF_SIZ))
|
|
||||||
return 1;
|
return 1;
|
||||||
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
|
||||||
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
|
||||||
if (type)
|
|
||||||
return j;
|
|
||||||
}
|
|
||||||
if (j < len)
|
|
||||||
return 0;
|
|
||||||
*u = udecoded;
|
|
||||||
utf8validate(u, len);
|
|
||||||
|
|
||||||
|
long cp = s[0] & leading_mask[len - 1];
|
||||||
|
for (int i = 1; i < len; ++i) {
|
||||||
|
if (s[i] == '\0' || (s[i] & 0xC0) != 0x80)
|
||||||
|
return i;
|
||||||
|
cp = (cp << 6) | (s[i] & 0x3F);
|
||||||
|
}
|
||||||
|
/* out of range, surrogate, overlong encoding */
|
||||||
|
if (cp > 0x10FFFF || (cp >> 11) == 0x1B || cp < overlong[len - 1])
|
||||||
|
return len;
|
||||||
|
|
||||||
|
*err = 0;
|
||||||
|
*u = cp;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,8 +178,7 @@ drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
|||||||
die("error, cannot allocate color '%s'", clrname);
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
/* Create color schemes. */
|
||||||
* returned color scheme when done using it. */
|
|
||||||
Clr *
|
Clr *
|
||||||
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
{
|
{
|
||||||
@@ -201,7 +186,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
Clr *ret;
|
Clr *ret;
|
||||||
|
|
||||||
/* need at least two colors for a scheme */
|
/* need at least two colors for a scheme */
|
||||||
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(Clr))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < clrcount; i++)
|
for (i = 0; i < clrcount; i++)
|
||||||
@@ -209,6 +194,30 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_clr_free(Drw *drw, Clr *c)
|
||||||
|
{
|
||||||
|
if (!drw || !c)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* c is typedef XftColor Clr */
|
||||||
|
XftColorFree(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
DefaultColormap(drw->dpy, drw->screen), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_scm_free(Drw *drw, Clr *scm, size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!drw || !scm)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
drw_clr_free(drw, &scm[i]);
|
||||||
|
free(scm);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
drw_setfontset(Drw *drw, Fnt *set)
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
{
|
{
|
||||||
@@ -238,11 +247,11 @@ drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int
|
|||||||
int
|
int
|
||||||
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
{
|
{
|
||||||
int i, ty, ellipsis_x = 0;
|
int ty, ellipsis_x = 0;
|
||||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *usedfont, *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
int utf8strlen, utf8charlen, render = x || y || w || h;
|
int utf8strlen, utf8charlen, utf8err, render = x || y || w || h;
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset;
|
||||||
@@ -251,9 +260,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
XftResult result;
|
XftResult result;
|
||||||
int charexists = 0, overflow = 0;
|
int charexists = 0, overflow = 0;
|
||||||
/* keep track of a couple codepoints for which we have no match. */
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
enum { nomatches_len = 64 };
|
static unsigned int nomatches[128], ellipsis_width, invalid_width;
|
||||||
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
static const char invalid[] = "<EFBFBD>";
|
||||||
static unsigned int ellipsis_width = 0;
|
|
||||||
|
|
||||||
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -263,6 +271,8 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
} else {
|
} else {
|
||||||
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
if (w < lpad)
|
||||||
|
return x + w;
|
||||||
d = XftDrawCreate(drw->dpy, drw->drawable,
|
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
DefaultVisual(drw->dpy, drw->screen),
|
DefaultVisual(drw->dpy, drw->screen),
|
||||||
DefaultColormap(drw->dpy, drw->screen));
|
DefaultColormap(drw->dpy, drw->screen));
|
||||||
@@ -273,12 +283,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
if (!ellipsis_width && render)
|
if (!ellipsis_width && render)
|
||||||
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
|
if (!invalid_width && render)
|
||||||
|
invalid_width = drw_fontset_getwidth(drw, invalid);
|
||||||
while (1) {
|
while (1) {
|
||||||
ew = ellipsis_len = utf8strlen = 0;
|
ew = ellipsis_len = utf8err = utf8charlen = utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
utf8charlen = utf8decode(text, &utf8codepoint, &utf8err);
|
||||||
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
if (charexists) {
|
if (charexists) {
|
||||||
@@ -300,9 +312,9 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
else
|
else
|
||||||
utf8strlen = ellipsis_len;
|
utf8strlen = ellipsis_len;
|
||||||
} else if (curfont == usedfont) {
|
} else if (curfont == usedfont) {
|
||||||
utf8strlen += utf8charlen;
|
|
||||||
text += utf8charlen;
|
text += utf8charlen;
|
||||||
ew += tmpw;
|
utf8strlen += utf8err ? 0 : utf8charlen;
|
||||||
|
ew += utf8err ? 0 : tmpw;
|
||||||
} else {
|
} else {
|
||||||
nextfont = curfont;
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
@@ -310,7 +322,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow || !charexists || nextfont)
|
if (overflow || !charexists || nextfont || utf8err)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
@@ -325,6 +337,12 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
x += ew;
|
x += ew;
|
||||||
w -= ew;
|
w -= ew;
|
||||||
}
|
}
|
||||||
|
if (utf8err && (!render || invalid_width < w)) {
|
||||||
|
if (render)
|
||||||
|
drw_text(drw, x, y, w, h, 0, invalid, invert);
|
||||||
|
x += invalid_width;
|
||||||
|
w -= invalid_width;
|
||||||
|
}
|
||||||
if (render && overflow)
|
if (render && overflow)
|
||||||
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
@@ -338,11 +356,14 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
* character must be drawn. */
|
* character must be drawn. */
|
||||||
charexists = 1;
|
charexists = 1;
|
||||||
|
|
||||||
for (i = 0; i < nomatches_len; ++i) {
|
hash = (unsigned int)utf8codepoint;
|
||||||
/* avoid calling XftFontMatch if we know we won't find a match */
|
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
||||||
if (utf8codepoint == nomatches.codepoint[i])
|
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
||||||
goto no_match;
|
h0 = ((hash >> 15) ^ hash) % LENGTH(nomatches);
|
||||||
}
|
h1 = (hash >> 17) % LENGTH(nomatches);
|
||||||
|
/* avoid expensive XftFontMatch call when we know we won't find a match */
|
||||||
|
if (nomatches[h0] == utf8codepoint || nomatches[h1] == utf8codepoint)
|
||||||
|
goto no_match;
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
@@ -371,7 +392,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
curfont->next = usedfont;
|
curfont->next = usedfont;
|
||||||
} else {
|
} else {
|
||||||
xfont_free(usedfont);
|
xfont_free(usedfont);
|
||||||
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
nomatches[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
||||||
no_match:
|
no_match:
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
|
|||||||
2
drw.h
2
drw.h
@@ -40,7 +40,9 @@ void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned in
|
|||||||
|
|
||||||
/* Colorscheme abstraction */
|
/* Colorscheme abstraction */
|
||||||
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
void drw_clr_free(Drw *drw, Clr *c);
|
||||||
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
void drw_scm_free(Drw *drw, Clr *scm, size_t clrcount);
|
||||||
|
|
||||||
/* Cursor abstraction */
|
/* Cursor abstraction */
|
||||||
Cur *drw_cur_create(Drw *drw, int shape);
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
|||||||
23
dwm.1
23
dwm.1
@@ -30,6 +30,14 @@ top left corner. The tags which are applied to one or more windows are
|
|||||||
indicated with an empty square in the top left corner.
|
indicated with an empty square in the top left corner.
|
||||||
.P
|
.P
|
||||||
dwm draws a small border around windows to indicate the focus state.
|
dwm draws a small border around windows to indicate the focus state.
|
||||||
|
.P
|
||||||
|
On start, dwm can start additional programs that may be specified in two special
|
||||||
|
shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||||
|
autostart.sh. The former is executed first and dwm will wait for its
|
||||||
|
termination before starting. The latter is executed in the background before
|
||||||
|
dwm enters its handler loop.
|
||||||
|
.P
|
||||||
|
Either of these files may be omitted.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
@@ -152,6 +160,21 @@ Toggles focused window between floating and tiled state.
|
|||||||
.TP
|
.TP
|
||||||
.B Mod1\-Button3
|
.B Mod1\-Button3
|
||||||
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||||
|
.SH FILES
|
||||||
|
The files containing programs to be started along with dwm are searched for in
|
||||||
|
the following directories:
|
||||||
|
.IP "1. $XDG_DATA_HOME/dwm"
|
||||||
|
.IP "2. $HOME/.local/share/dwm"
|
||||||
|
.IP "3. $HOME/.dwm"
|
||||||
|
.P
|
||||||
|
The first existing directory is scanned for any of the autostart files below.
|
||||||
|
.TP 15
|
||||||
|
autostart.sh
|
||||||
|
This file is started as a shell background process before dwm enters its handler
|
||||||
|
loop.
|
||||||
|
.TP 15
|
||||||
|
autostart_blocking.sh
|
||||||
|
This file is started before any autostart.sh; dwm waits for its termination.
|
||||||
.SH CUSTOMIZATION
|
.SH CUSTOMIZATION
|
||||||
dwm is customized by creating a custom config.h and (re)compiling the source
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
code. This keeps it fast, secure and simple.
|
code. This keeps it fast, secure and simple.
|
||||||
|
|||||||
127
dwm.c
127
dwm.c
@@ -29,6 +29,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
@@ -50,7 +51,6 @@
|
|||||||
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
#define INTERSECT(x,y,w,h,m) (MAX(0, MIN((x)+(w),(m)->wx+(m)->ww) - MAX((x),(m)->wx)) \
|
||||||
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
* MAX(0, MIN((y)+(h),(m)->wy+(m)->wh) - MAX((y),(m)->wy)))
|
||||||
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
#define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags]))
|
||||||
#define LENGTH(X) (sizeof X / sizeof X[0])
|
|
||||||
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
#define MOUSEMASK (BUTTONMASK|PointerMotionMask)
|
||||||
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
#define WIDTH(X) ((X)->w + 2 * (X)->bw)
|
||||||
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
#define HEIGHT(X) ((X)->h + 2 * (X)->bw)
|
||||||
@@ -119,6 +119,7 @@ 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];
|
||||||
@@ -194,12 +195,14 @@ 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);
|
||||||
static void restack(Monitor *m);
|
static void restack(Monitor *m);
|
||||||
static void run(void);
|
static void run(void);
|
||||||
|
static void runautostart(void);
|
||||||
static void scan(void);
|
static void scan(void);
|
||||||
static int sendevent(Client *c, Atom proto);
|
static int sendevent(Client *c, Atom proto);
|
||||||
static void sendmon(Client *c, Monitor *m);
|
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);
|
||||||
@@ -235,7 +238,11 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
|||||||
static void zoom(const Arg *arg);
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
/* variables */
|
/* variables */
|
||||||
|
static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||||
|
static const char autostartsh[] = "autostart.sh";
|
||||||
static const char broken[] = "broken";
|
static const char broken[] = "broken";
|
||||||
|
static const char dwmdir[] = "dwm";
|
||||||
|
static const char localshare[] = ".local/share";
|
||||||
static char stext[256];
|
static char stext[256];
|
||||||
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 */
|
||||||
@@ -487,7 +494,7 @@ cleanup(void)
|
|||||||
for (i = 0; i < CurLast; i++)
|
for (i = 0; i < CurLast; i++)
|
||||||
drw_cur_free(drw, cursor[i]);
|
drw_cur_free(drw, cursor[i]);
|
||||||
for (i = 0; i < LENGTH(colors); i++)
|
for (i = 0; i < LENGTH(colors); i++)
|
||||||
free(scheme[i]);
|
drw_scm_free(drw, scheme[i], 3);
|
||||||
free(scheme);
|
free(scheme);
|
||||||
XDestroyWindow(dpy, wmcheckwin);
|
XDestroyWindow(dpy, wmcheckwin);
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
@@ -641,6 +648,7 @@ 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);
|
||||||
@@ -1172,7 +1180,7 @@ movemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@@ -1326,7 +1334,7 @@ resizemouse(const Arg *arg)
|
|||||||
handler[ev.type](&ev);
|
handler[ev.type](&ev);
|
||||||
break;
|
break;
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
if ((ev.xmotion.time - lasttime) <= (1000 / 60))
|
if ((ev.xmotion.time - lasttime) <= (1000 / refreshrate))
|
||||||
continue;
|
continue;
|
||||||
lasttime = ev.xmotion.time;
|
lasttime = ev.xmotion.time;
|
||||||
|
|
||||||
@@ -1390,6 +1398,83 @@ run(void)
|
|||||||
handler[ev.type](&ev); /* call handler */
|
handler[ev.type](&ev); /* call handler */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runautostart(void)
|
||||||
|
{
|
||||||
|
char *pathpfx;
|
||||||
|
char *path;
|
||||||
|
char *xdgdatahome;
|
||||||
|
char *home;
|
||||||
|
struct stat sb;
|
||||||
|
|
||||||
|
if ((home = getenv("HOME")) == NULL)
|
||||||
|
/* this is almost impossible */
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
|
||||||
|
* otherwise use ~/.local/share/dwm as autostart script directory
|
||||||
|
*/
|
||||||
|
xdgdatahome = getenv("XDG_DATA_HOME");
|
||||||
|
if (xdgdatahome != NULL && *xdgdatahome != '\0') {
|
||||||
|
/* space for path segments, separators and nul */
|
||||||
|
pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
|
||||||
|
|
||||||
|
if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
|
||||||
|
free(pathpfx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* space for path segments, separators and nul */
|
||||||
|
pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
|
||||||
|
+ strlen(dwmdir) + 3);
|
||||||
|
|
||||||
|
if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
|
||||||
|
free(pathpfx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if the autostart script directory exists */
|
||||||
|
if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||||
|
/* the XDG conformant path does not exist or is no directory
|
||||||
|
* so we try ~/.dwm instead
|
||||||
|
*/
|
||||||
|
char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
|
||||||
|
if(pathpfx_new == NULL) {
|
||||||
|
free(pathpfx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pathpfx = pathpfx_new;
|
||||||
|
|
||||||
|
if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
|
||||||
|
free(pathpfx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* try the blocking script first */
|
||||||
|
path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
|
||||||
|
if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
|
||||||
|
free(path);
|
||||||
|
free(pathpfx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(path, X_OK) == 0)
|
||||||
|
system(path);
|
||||||
|
|
||||||
|
/* now the non-blocking script */
|
||||||
|
if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
|
||||||
|
free(path);
|
||||||
|
free(pathpfx);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(path, X_OK) == 0)
|
||||||
|
system(strcat(path, " &"));
|
||||||
|
|
||||||
|
free(pathpfx);
|
||||||
|
free(path);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scan(void)
|
scan(void)
|
||||||
{
|
{
|
||||||
@@ -1507,6 +1592,15 @@ 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)
|
||||||
{
|
{
|
||||||
@@ -1697,18 +1791,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;
|
mw = m->ww - m->gappx;
|
||||||
for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
|
for (i = 0, my = ty = m->gappx, 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);
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i) - m->gappx;
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
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->wh)
|
if (my + HEIGHT(c) + m->gappx < m->wh)
|
||||||
my += HEIGHT(c);
|
my += HEIGHT(c) + m->gappx;
|
||||||
} else {
|
} else {
|
||||||
h = (m->wh - ty) / (n - i);
|
h = (m->wh - ty) / (n - i) - m->gappx;
|
||||||
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
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->wh)
|
if (ty + HEIGHT(c) + m->gappx < m->wh)
|
||||||
ty += HEIGHT(c);
|
ty += HEIGHT(c) + m->gappx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1851,7 +1945,7 @@ updatebarpos(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updateclientlist()
|
updateclientlist(void)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
@@ -2158,6 +2252,7 @@ main(int argc, char *argv[])
|
|||||||
die("pledge");
|
die("pledge");
|
||||||
#endif /* __OpenBSD__ */
|
#endif /* __OpenBSD__ */
|
||||||
scan();
|
scan();
|
||||||
|
runautostart();
|
||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
|||||||
179
patches/dwm-autostart-20210120-cb3f58a.diff
Normal file
179
patches/dwm-autostart-20210120-cb3f58a.diff
Normal file
@@ -0,0 +1,179 @@
|
|||||||
|
From 37e970479dc5d40e57fc0cbfeaa5e39941483237 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Gan Ainm <gan.ainm.riomhphost@gmail.com>
|
||||||
|
Date: Wed, 10 Jun 2020 10:59:02 +0000
|
||||||
|
Subject: [PATCH] dwm-xdgautostart-6.2.diff
|
||||||
|
|
||||||
|
===================================================================
|
||||||
|
---
|
||||||
|
dwm.1 | 23 +++++++++++++++++
|
||||||
|
dwm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 105 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/dwm.1 b/dwm.1
|
||||||
|
index 13b3729..9533aa6 100644
|
||||||
|
--- a/dwm.1
|
||||||
|
+++ b/dwm.1
|
||||||
|
@@ -30,6 +30,14 @@ top left corner. The tags which are applied to one or more windows are
|
||||||
|
indicated with an empty square in the top left corner.
|
||||||
|
.P
|
||||||
|
dwm draws a small border around windows to indicate the focus state.
|
||||||
|
+.P
|
||||||
|
+On start, dwm can start additional programs that may be specified in two special
|
||||||
|
+shell scripts (see the FILES section below), autostart_blocking.sh and
|
||||||
|
+autostart.sh. The former is executed first and dwm will wait for its
|
||||||
|
+termination before starting. The latter is executed in the background before
|
||||||
|
+dwm enters its handler loop.
|
||||||
|
+.P
|
||||||
|
+Either of these files may be omitted.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
|
@@ -152,6 +160,21 @@ Toggles focused window between floating and tiled state.
|
||||||
|
.TP
|
||||||
|
.B Mod1\-Button3
|
||||||
|
Resize focused window while dragging. Tiled windows will be toggled to the floating state.
|
||||||
|
+.SH FILES
|
||||||
|
+The files containing programs to be started along with dwm are searched for in
|
||||||
|
+the following directories:
|
||||||
|
+.IP "1. $XDG_DATA_HOME/dwm"
|
||||||
|
+.IP "2. $HOME/.local/share/dwm"
|
||||||
|
+.IP "3. $HOME/.dwm"
|
||||||
|
+.P
|
||||||
|
+The first existing directory is scanned for any of the autostart files below.
|
||||||
|
+.TP 15
|
||||||
|
+autostart.sh
|
||||||
|
+This file is started as a shell background process before dwm enters its handler
|
||||||
|
+loop.
|
||||||
|
+.TP 15
|
||||||
|
+autostart_blocking.sh
|
||||||
|
+This file is started before any autostart.sh; dwm waits for its termination.
|
||||||
|
.SH CUSTOMIZATION
|
||||||
|
dwm is customized by creating a custom config.h and (re)compiling the source
|
||||||
|
code. This keeps it fast, secure and simple.
|
||||||
|
diff --git a/dwm.c b/dwm.c
|
||||||
|
index 4465af1..2156b49 100644
|
||||||
|
--- a/dwm.c
|
||||||
|
+++ b/dwm.c
|
||||||
|
@@ -29,6 +29,7 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
+#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
@@ -193,6 +194,7 @@ static void resizeclient(Client *c, int x, int y, int w, int h);
|
||||||
|
static void resizemouse(const Arg *arg);
|
||||||
|
static void restack(Monitor *m);
|
||||||
|
static void run(void);
|
||||||
|
+static void runautostart(void);
|
||||||
|
static void scan(void);
|
||||||
|
static int sendevent(Client *c, Atom proto);
|
||||||
|
static void sendmon(Client *c, Monitor *m);
|
||||||
|
@@ -235,7 +237,11 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee);
|
||||||
|
static void zoom(const Arg *arg);
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
+static const char autostartblocksh[] = "autostart_blocking.sh";
|
||||||
|
+static const char autostartsh[] = "autostart.sh";
|
||||||
|
static const char broken[] = "broken";
|
||||||
|
+static const char dwmdir[] = "dwm";
|
||||||
|
+static const char localshare[] = ".local/share";
|
||||||
|
static char stext[256];
|
||||||
|
static int screen;
|
||||||
|
static int sw, sh; /* X display screen geometry width, height */
|
||||||
|
@@ -1380,6 +1386,83 @@ run(void)
|
||||||
|
handler[ev.type](&ev); /* call handler */
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+runautostart(void)
|
||||||
|
+{
|
||||||
|
+ char *pathpfx;
|
||||||
|
+ char *path;
|
||||||
|
+ char *xdgdatahome;
|
||||||
|
+ char *home;
|
||||||
|
+ struct stat sb;
|
||||||
|
+
|
||||||
|
+ if ((home = getenv("HOME")) == NULL)
|
||||||
|
+ /* this is almost impossible */
|
||||||
|
+ return;
|
||||||
|
+
|
||||||
|
+ /* if $XDG_DATA_HOME is set and not empty, use $XDG_DATA_HOME/dwm,
|
||||||
|
+ * otherwise use ~/.local/share/dwm as autostart script directory
|
||||||
|
+ */
|
||||||
|
+ xdgdatahome = getenv("XDG_DATA_HOME");
|
||||||
|
+ if (xdgdatahome != NULL && *xdgdatahome != '\0') {
|
||||||
|
+ /* space for path segments, separators and nul */
|
||||||
|
+ pathpfx = ecalloc(1, strlen(xdgdatahome) + strlen(dwmdir) + 2);
|
||||||
|
+
|
||||||
|
+ if (sprintf(pathpfx, "%s/%s", xdgdatahome, dwmdir) <= 0) {
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ /* space for path segments, separators and nul */
|
||||||
|
+ pathpfx = ecalloc(1, strlen(home) + strlen(localshare)
|
||||||
|
+ + strlen(dwmdir) + 3);
|
||||||
|
+
|
||||||
|
+ if (sprintf(pathpfx, "%s/%s/%s", home, localshare, dwmdir) < 0) {
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* check if the autostart script directory exists */
|
||||||
|
+ if (! (stat(pathpfx, &sb) == 0 && S_ISDIR(sb.st_mode))) {
|
||||||
|
+ /* the XDG conformant path does not exist or is no directory
|
||||||
|
+ * so we try ~/.dwm instead
|
||||||
|
+ */
|
||||||
|
+ char *pathpfx_new = realloc(pathpfx, strlen(home) + strlen(dwmdir) + 3);
|
||||||
|
+ if(pathpfx_new == NULL) {
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ pathpfx = pathpfx_new;
|
||||||
|
+
|
||||||
|
+ if (sprintf(pathpfx, "%s/.%s", home, dwmdir) <= 0) {
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* try the blocking script first */
|
||||||
|
+ path = ecalloc(1, strlen(pathpfx) + strlen(autostartblocksh) + 2);
|
||||||
|
+ if (sprintf(path, "%s/%s", pathpfx, autostartblocksh) <= 0) {
|
||||||
|
+ free(path);
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (access(path, X_OK) == 0)
|
||||||
|
+ system(path);
|
||||||
|
+
|
||||||
|
+ /* now the non-blocking script */
|
||||||
|
+ if (sprintf(path, "%s/%s", pathpfx, autostartsh) <= 0) {
|
||||||
|
+ free(path);
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (access(path, X_OK) == 0)
|
||||||
|
+ system(strcat(path, " &"));
|
||||||
|
+
|
||||||
|
+ free(pathpfx);
|
||||||
|
+ free(path);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
scan(void)
|
||||||
|
{
|
||||||
|
@@ -2142,6 +2223,7 @@ main(int argc, char *argv[])
|
||||||
|
die("pledge");
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
|
scan();
|
||||||
|
+ runautostart();
|
||||||
|
run();
|
||||||
|
cleanup();
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
94
patches/dwm-fullgaps-6.4.diff
Normal file
94
patches/dwm-fullgaps-6.4.diff
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
diff -up a/config.def.h b/config.def.h
|
||||||
|
--- 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 */
|
||||||
|
@@ -85,6 +86,9 @@ static const 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 -up a/dwm.c b/dwm.c
|
||||||
|
--- a/dwm.c 2023-04-30
|
||||||
|
+++ b/dwm.c 2023-04-30
|
||||||
|
@@ -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 *
|
||||||
|
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);
|
||||||
|
@@ -641,6 +643,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);
|
||||||
|
@@ -1508,6 +1511,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)
|
||||||
|
{
|
||||||
|
if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
|
||||||
|
@@ -1697,18 +1710,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++)
|
||||||
|
- 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);
|
||||||
|
+ 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) - 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
util.c
13
util.c
@@ -1,4 +1,5 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -10,17 +11,17 @@ void
|
|||||||
die(const char *fmt, ...)
|
die(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int saved_errno;
|
||||||
|
|
||||||
|
saved_errno = errno;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
if (fmt[0] && fmt[strlen(fmt)-1] == ':')
|
||||||
fputc(' ', stderr);
|
fprintf(stderr, " %s", strerror(saved_errno));
|
||||||
perror(NULL);
|
fputc('\n', stderr);
|
||||||
} else {
|
|
||||||
fputc('\n', stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
1
util.h
1
util.h
@@ -3,6 +3,7 @@
|
|||||||
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||||
|
#define LENGTH(X) (sizeof (X) / sizeof (X)[0])
|
||||||
|
|
||||||
void die(const char *fmt, ...);
|
void die(const char *fmt, ...);
|
||||||
void *ecalloc(size_t nmemb, size_t size);
|
void *ecalloc(size_t nmemb, size_t size);
|
||||||
|
|||||||
Reference in New Issue
Block a user