Customize everything

This commit is contained in:
Bill Rossi 2026-01-24 06:44:58 -05:00
parent a9aa0d8ffb
commit 3d214f688d
3 changed files with 48 additions and 16 deletions

View File

@ -20,7 +20,7 @@ dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}
clean:
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h
dist: clean
mkdir -p dwm-${VERSION}

View File

@ -19,7 +19,7 @@ static const char *colors[][3] = {
};
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" };
static const Rule rules[] = {
/* xprop(1):
@ -27,8 +27,8 @@ static const Rule rules[] = {
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
{ "Gimp", NULL, NULL, 0, 1, -1 },
/* { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, */
};
/* layout(s) */
@ -46,7 +46,7 @@ static const Layout layouts[] = {
};
/* key definitions */
#define MODKEY Mod1Mask
#define MODKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
@ -60,28 +60,35 @@ static const Layout layouts[] = {
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
static const char *termcmd[] = { "st", NULL };
static const char *screenshotcmd[] = { "/home/bill/scripts/screenshot", NULL };
static const char *emacscmd[] = { "emacs", NULL };
static const char *firefoxcmd[] = { "firefox", NULL };
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
{ MODKEY, XK_d, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
{ 0, XK_Print, spawn, {.v = screenshotcmd } },
{ MODKEY, XK_e, spawn, {.v = emacscmd } },
{ MODKEY, XK_f, spawn, {.v = firefoxcmd } },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1 } },
{ MODKEY, XK_k, focusstack, {.i = -1 } },
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
/* { MODKEY, XK_i, incnmaster, {.i = +1 } }, */
/* { MODKEY, XK_d, incnmaster, {.i = -1 } }, */
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, killclient, {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_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
/* { MODKEY, XK_0, view, {.ui = ~0 } }, */
/* { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, */
{ MODKEY, XK_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
@ -95,7 +102,8 @@ static const Key keys[] = {
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
TAGKEYS( XK_0, 9)
{ MODKEY|ShiftMask, XK_e, quit, {0} },
};
/* button definitions */

30
dwm.c
View File

@ -177,6 +177,7 @@ static void grabkeys(void);
static void incnmaster(const Arg *arg);
static void keypress(XEvent *e);
static void killclient(const Arg *arg);
static int log_2(int i);
static void manage(Window w, XWindowAttributes *wa);
static void mappingnotify(XEvent *e);
static void maprequest(XEvent *e);
@ -196,6 +197,7 @@ static void run(void);
static void scan(void);
static int sendevent(Client *c, Atom proto);
static void sendmon(Client *c, Monitor *m);
static void setbackgroundimage(size_t index);
static void setclientstate(Client *c, long state);
static void setfocus(Client *c);
static void setfullscreen(Client *c, int fullscreen);
@ -1385,6 +1387,7 @@ run(void)
XEvent ev;
/* main event loop */
XSync(dpy, False);
setbackgroundimage(0);
while (running && !XNextEvent(dpy, &ev))
if (handler[ev.type])
handler[ev.type](&ev); /* call handler */
@ -1433,6 +1436,16 @@ sendmon(Client *c, Monitor *m)
arrange(NULL);
}
void
setbackgroundimage(size_t index)
{
char imagepath[50];
sprintf(imagepath, "/home/bill/images/bg/bg-%ld.png", index % 10);
if (fork() == 0) {
execlp("feh", "--nofehbg", "--bg-fill", imagepath);
}
}
void
setclientstate(Client *c, long state)
{
@ -2050,16 +2063,27 @@ updatewmhints(Client *c)
}
}
int
log_2(int i)
{
int l = 0;
while (i >>= 1) { ++l; }
return l;
}
void
view(const Arg *arg)
{
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
const int ui = arg->ui;
if ((ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
if (arg->ui & TAGMASK)
selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
if (ui & TAGMASK)
selmon->tagset[selmon->seltags] = ui & TAGMASK;
focus(NULL);
arrange(selmon);
if (arg->ui != ~0)
setbackgroundimage(log_2(arg->ui));
}
Client *