Compare commits
No commits in common. "c094ad31c39f129ec3d007ee0bfb44ba45f7a24e" and "e81f17d4c196aaed6893fd4beed49991caa3e2a4" have entirely different histories.
c094ad31c3
...
e81f17d4c1
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +0,0 @@
|
|||||||
dwm
|
|
||||||
*.o
|
|
||||||
*.orig
|
|
||||||
config.h
|
|
||||||
transient
|
|
22
Makefile
22
Makefile
@ -6,32 +6,40 @@ include config.mk
|
|||||||
SRC = drw.c dwm.c util.c
|
SRC = drw.c dwm.c util.c
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
all: dwm
|
all: options dwm
|
||||||
|
|
||||||
|
options:
|
||||||
|
@echo dwm build options:
|
||||||
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
|
@echo "CC = ${CC}"
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
${CC} -c ${CFLAGS} $<
|
${CC} -c ${CFLAGS} $<
|
||||||
|
|
||||||
${OBJ}: config.def.h config.mk
|
${OBJ}: config.h config.mk
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
cp config.def.h $@
|
||||||
|
|
||||||
dwm: ${OBJ}
|
dwm: ${OBJ}
|
||||||
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h
|
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
|
||||||
|
|
||||||
dist: clean
|
dist: clean
|
||||||
mkdir -p dwm-${VERSION}
|
mkdir -p dwm-${VERSION}
|
||||||
cp -R LICENSE Makefile README config.def.h config.mk\
|
cp -R LICENSE Makefile README config.def.h config.mk\
|
||||||
dwm.1 drw.h util.h dwm_random_bg.sh ${SRC} dwm.png transient.c dwm-${VERSION}
|
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
|
||||||
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
|
||||||
gzip dwm-${VERSION}.tar
|
gzip dwm-${VERSION}.tar
|
||||||
rm -rf dwm-${VERSION}
|
rm -rf dwm-${VERSION}
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
mkdir -p ${DESTDIR}${PREFIX}/bin
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
cp -f dwm dwm_random_bg.sh ${DESTDIR}${PREFIX}/bin
|
cp -f dwm ${DESTDIR}${PREFIX}/bin
|
||||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
|
||||||
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm_random_bg.sh
|
|
||||||
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
@ -40,4 +48,4 @@ uninstall:
|
|||||||
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
|
||||||
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
${DESTDIR}${MANPREFIX}/man1/dwm.1
|
||||||
|
|
||||||
.PHONY: all clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
59
config.def.h
59
config.def.h
@ -1,36 +1,21 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
#include <X11/XF86keysym.h>
|
|
||||||
#include <X11/XKBlib.h>
|
|
||||||
|
|
||||||
/* Function to toggle between the two layouts */
|
|
||||||
void toggle_keyboard_layout(const Arg* arg) {
|
|
||||||
XkbStateRec state;
|
|
||||||
if (XkbGetState(dpy, XkbUseCoreKbd, &state) != Success) {
|
|
||||||
fprintf(stderr, "Failed to get keyboard state\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* Toggle: if current group is 0 (English), switch to 1 (Russian), and vice versa */
|
|
||||||
unsigned int newGroup = (state.group == 0) ? 1 : 0;
|
|
||||||
if (XkbLockGroup(dpy, XkbUseCoreKbd, newGroup) != True) {
|
|
||||||
fprintf(stderr, "Failed to toggle keyboard layout\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Normal config.def.h continues. I just added some of my own functions
|
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
static const unsigned int borderpx = 1; /* border pixel of windows */
|
||||||
static const unsigned int gappx = 2; /* gap pixel 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[] = { "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_gray2[] = "#444444";
|
||||||
|
static const char col_gray3[] = "#bbbbbb";
|
||||||
|
static const char col_gray4[] = "#eeeeee";
|
||||||
|
static const char col_cyan[] = "#005577";
|
||||||
static const char *colors[][3] = {
|
static const char *colors[][3] = {
|
||||||
/* fg bg border */
|
/* fg bg border */
|
||||||
[SchemeNorm] = { "#eeeeee", "#222222", "#111111" },
|
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
||||||
[SchemeSel] = { "#ffffff", "#e00000", "#e00000" },
|
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
@ -60,7 +45,7 @@ static const Layout layouts[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* key definitions */
|
/* key definitions */
|
||||||
#define MODKEY Mod4Mask
|
#define MODKEY Mod1Mask
|
||||||
#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} }, \
|
||||||
@ -72,34 +57,28 @@ 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_old[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
|
||||||
static const char *termcmd[] = { "st", NULL };
|
static const char *termcmd[] = { "st", NULL };
|
||||||
static const char *flexcmd[]= {"st", "-g", "115x29", "-e", "sh", "-c", "neofetch; sleep 100", NULL};
|
|
||||||
static const char *dmenucmd[] = {"dmenu_run.sh", NULL};
|
|
||||||
static const char* termtmuxzshcmd[] = {"st", "-e", "tmux", "new-session", "zsh", NULL};
|
|
||||||
|
|
||||||
static const Key keys[] = {
|
static const Key keys[] = {
|
||||||
/* modifier key function argument */
|
/* modifier key function argument */
|
||||||
{ MODKEY, XK_space, toggle_keyboard_layout, {0} },
|
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
||||||
{ MODKEY, XK_r, spawn, {.v = dmenucmd } },
|
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
||||||
{ MODKEY|ControlMask, XK_s, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_s, spawn, {.v = termtmuxzshcmd } },
|
|
||||||
{ MODKEY|ControlMask, XK_n, spawn, {.v = flexcmd } },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
{ MODKEY, XK_b, togglebar, {0} },
|
||||||
{ MODKEY, XK_k, focusstack, {.i = +1 } },
|
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
||||||
{ MODKEY, XK_l, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_j, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_semicolon , setmfact, {.f = +0.05} },
|
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
{ MODKEY|Mod1Mask , XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
|
||||||
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
|
||||||
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
|
||||||
//{ MODKEY, XK_space, setlayout, {0} },
|
{ MODKEY, XK_space, setlayout, {0} },
|
||||||
{ MODKEY|ControlMask, XK_space, togglefloating, {0} },
|
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||||
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
{ MODKEY, XK_0, view, {.ui = ~0 } },
|
||||||
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
|
||||||
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# dwm version
|
# dwm version
|
||||||
VERSION = 6.5
|
VERSION = 6.4
|
||||||
|
|
||||||
# Customize below to fit your system
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
118
drw.c
118
drw.c
@ -9,40 +9,54 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define UTF_INVALID 0xFFFD
|
#define UTF_INVALID 0xFFFD
|
||||||
|
#define UTF_SIZ 4
|
||||||
|
|
||||||
static int
|
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
utf8decode(const char *s_in, long *u, int *err)
|
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
static const unsigned char lens[] = {
|
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||||
/* 0XXXX */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||||
/* 10XXX */ 0, 0, 0, 0, 0, 0, 0, 0, /* invalid */
|
return (unsigned char)c & ~utfmask[*i];
|
||||||
/* 110XX */ 2, 2, 2, 2,
|
return 0;
|
||||||
/* 1110X */ 3, 3,
|
|
||||||
/* 11110 */ 4,
|
|
||||||
/* 11111 */ 0, /* invalid */
|
|
||||||
};
|
|
||||||
static const unsigned char leading_mask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
|
|
||||||
static const unsigned int overlong[] = { 0x0, 0x80, 0x0800, 0x10000 };
|
|
||||||
|
|
||||||
const unsigned char *s = (const unsigned char *)s_in;
|
|
||||||
int len = lens[*s >> 3];
|
|
||||||
*u = UTF_INVALID;
|
|
||||||
*err = 1;
|
|
||||||
if (len == 0)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
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;
|
static size_t
|
||||||
*u = cp;
|
utf8validate(long *u, size_t i)
|
||||||
|
{
|
||||||
|
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||||
|
*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;
|
||||||
|
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
if (!clen)
|
||||||
|
return 0;
|
||||||
|
udecoded = utf8decodebyte(c[0], &len);
|
||||||
|
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||||
|
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);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,11 +238,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 ty, ellipsis_x = 0;
|
int i, ty, ellipsis_x = 0;
|
||||||
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len, hash, h0, h1;
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||||
XftDraw *d = NULL;
|
XftDraw *d = NULL;
|
||||||
Fnt *usedfont, *curfont, *nextfont;
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
int utf8strlen, utf8charlen, utf8err, render = x || y || w || h;
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
long utf8codepoint = 0;
|
long utf8codepoint = 0;
|
||||||
const char *utf8str;
|
const char *utf8str;
|
||||||
FcCharSet *fccharset;
|
FcCharSet *fccharset;
|
||||||
@ -237,8 +251,9 @@ 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. */
|
||||||
static unsigned int nomatches[128], ellipsis_width, invalid_width;
|
enum { nomatches_len = 64 };
|
||||||
static const char invalid[] = "<EFBFBD>";
|
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||||
|
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;
|
||||||
@ -248,8 +263,6 @@ 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));
|
||||||
@ -260,14 +273,12 @@ 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 = utf8err = utf8charlen = utf8strlen = 0;
|
ew = ellipsis_len = utf8strlen = 0;
|
||||||
utf8str = text;
|
utf8str = text;
|
||||||
nextfont = NULL;
|
nextfont = NULL;
|
||||||
while (*text) {
|
while (*text) {
|
||||||
utf8charlen = utf8decode(text, &utf8codepoint, &utf8err);
|
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||||
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) {
|
||||||
@ -289,9 +300,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;
|
||||||
utf8strlen += utf8err ? 0 : utf8charlen;
|
ew += tmpw;
|
||||||
ew += utf8err ? 0 : tmpw;
|
|
||||||
} else {
|
} else {
|
||||||
nextfont = curfont;
|
nextfont = curfont;
|
||||||
}
|
}
|
||||||
@ -299,7 +310,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (overflow || !charexists || nextfont || utf8err)
|
if (overflow || !charexists || nextfont)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
charexists = 0;
|
charexists = 0;
|
||||||
@ -314,12 +325,6 @@ 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);
|
||||||
|
|
||||||
@ -333,14 +338,11 @@ 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;
|
||||||
|
|
||||||
hash = (unsigned int)utf8codepoint;
|
for (i = 0; i < nomatches_len; ++i) {
|
||||||
hash = ((hash >> 16) ^ hash) * 0x21F0AAAD;
|
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||||
hash = ((hash >> 15) ^ hash) * 0xD35A2D97;
|
if (utf8codepoint == nomatches.codepoint[i])
|
||||||
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;
|
goto no_match;
|
||||||
|
}
|
||||||
|
|
||||||
fccharset = FcCharSetCreate();
|
fccharset = FcCharSetCreate();
|
||||||
FcCharSetAddChar(fccharset, utf8codepoint);
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
@ -369,7 +371,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[nomatches[h0] ? h1 : h0] = utf8codepoint;
|
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||||
no_match:
|
no_match:
|
||||||
usedfont = drw->fonts;
|
usedfont = drw->fonts;
|
||||||
}
|
}
|
||||||
|
32
dwm.c
32
dwm.c
@ -50,6 +50,7 @@
|
|||||||
#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)
|
||||||
@ -268,7 +269,7 @@ static Monitor *mons, *selmon;
|
|||||||
static Window root, wmcheckwin;
|
static Window root, wmcheckwin;
|
||||||
|
|
||||||
/* configuration, allows nested code to access above variables */
|
/* configuration, allows nested code to access above variables */
|
||||||
#include "config.def.h"
|
#include "config.h"
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; };
|
||||||
@ -1683,10 +1684,10 @@ tagmon(const Arg *arg)
|
|||||||
sendmon(selmon->sel, dirtomon(arg->i));
|
sendmon(selmon->sel, dirtomon(arg->i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: There was thishuge conflict with 6.0+gaps patch and I merged it almost blindly. Have no guarantees that it willwork correctly
|
|
||||||
void
|
void
|
||||||
tile(Monitor *m) {
|
tile(Monitor *m)
|
||||||
unsigned int i, n, h, r, g = 0, mw, my, ty;
|
{
|
||||||
|
unsigned int i, n, h, mw, my, ty;
|
||||||
Client *c;
|
Client *c;
|
||||||
|
|
||||||
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
|
||||||
@ -1694,21 +1695,20 @@ tile(Monitor *m) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (n > m->nmaster)
|
if (n > m->nmaster)
|
||||||
mw = m->nmaster ? (m->ww - (g = gappx)) * m->mfact : 0;
|
mw = m->nmaster ? m->ww * m->mfact : 0;
|
||||||
else
|
else
|
||||||
mw = m->ww;
|
mw = m->ww;
|
||||||
for (i = my = ty = 0, 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) {
|
||||||
r = MIN(n, m->nmaster) - i;
|
h = (m->wh - my) / (MIN(n, m->nmaster) - i);
|
||||||
h = (m->wh - my - gappx * (r - 1)) / r;
|
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
|
if (my + HEIGHT(c) < m->wh)
|
||||||
my += HEIGHT(c) + gappx;
|
my += HEIGHT(c);
|
||||||
}
|
} else {
|
||||||
else {
|
h = (m->wh - ty) / (n - i);
|
||||||
r = n - i;
|
resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
|
||||||
h = (m->wh - ty - gappx * (r - 1)) / r;
|
if (ty + HEIGHT(c) < m->wh)
|
||||||
resize(c, m->wx + mw + g, m->wy + ty, m->ww - mw - g - (2*c->bw), h - (2*c->bw), False);
|
ty += HEIGHT(c);
|
||||||
ty += HEIGHT(c) + gappx;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1851,7 +1851,7 @@ updatebarpos(Monitor *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
updateclientlist(void)
|
updateclientlist()
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Monitor *m;
|
Monitor *m;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Directory containing wallpapers
|
|
||||||
WALLPAPER_DIR="$HOME/.config/suckless_desktop/wallpaper"
|
|
||||||
|
|
||||||
# Find all .png, .jpg, and .jpwg files (case-insensitive)
|
|
||||||
files=( $(find "$WALLPAPER_DIR" -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpwg" \)) )
|
|
||||||
|
|
||||||
# Check if we found any wallpapers
|
|
||||||
if [ ${#files[@]} -eq 0 ]; then
|
|
||||||
echo "No wallpaper files found in $WALLPAPER_DIR."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Choose a random file from the array
|
|
||||||
RANDOM_FILE="${files[RANDOM % ${#files[@]}]}"
|
|
||||||
|
|
||||||
# Set the chosen file as the wallpaper using xwallpaper
|
|
||||||
xwallpaper --zoom "$RANDOM_FILE"
|
|
||||||
|
|
11
util.c
11
util.c
@ -1,5 +1,4 @@
|
|||||||
/* 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>
|
||||||
@ -11,17 +10,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] == ':') {
|
||||||
fprintf(stderr, " %s", strerror(saved_errno));
|
fputc(' ', stderr);
|
||||||
|
perror(NULL);
|
||||||
|
} else {
|
||||||
fputc('\n', stderr);
|
fputc('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
1
util.h
1
util.h
@ -3,7 +3,6 @@
|
|||||||
#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);
|
||||||
|
Loading…
Reference in New Issue
Block a user