Compare commits

...

9 Commits
6.6 ... master

Author SHA1 Message Date
Aaron Lindsay
95314cf373 config.h: Update for upstream 6.6 2025-12-11 09:30:57 -05:00
Aaron Lindsay
37ca25f801 Update config.h for 138b405f0c "Add a configuration option for fullscreen locking" 2025-12-11 09:22:52 -05:00
Aaron Lindsay
bc0526151c config.h: Add urgent and warning color schemes 2025-12-11 09:22:52 -05:00
Aaron Lindsay
04f6c0107b Apply updated statuscolors patch from
https://dwm.suckless.org/patches/statuscolors/ and
https://dwm.suckless.org/patches/statuscolors/dwm-statuscolors-20220322-bece862.diff

From 301db3986527041d64f4b58026677709a34b153f Mon Sep 17 00:00:00 2001
From: dan soucy <dev@danso.ca>
Date: Tue, 22 Mar 2022 03:15:00 -0400
Subject: [PATCH] enable colored text in the status bar

This patch is an update of statuscolors patch to work with 6.3.
It is known to work up to commit bece862.
---
 config.def.h | 13 ++++++++++---
 dwm.c        | 18 ++++++++++++++++--
 2 files changed, 26 insertions(+), 5 deletions(-)
2025-12-11 09:22:52 -05:00
Aaron Lindsay
b82a6185d4 Add initial config file 2025-12-11 09:22:52 -05:00
Aaron Lindsay
d9df33a083 Apply 'push' patch
From http://dwm.suckless.org/patches/push
2025-12-11 09:22:52 -05:00
Hiltjo Posthuma
7c3abae4e6 drw.c: drw_scm_free: call free inside
Because drw_scm_create() allocates it.
2025-09-29 18:48:27 +02:00
Hiltjo Posthuma
93f26863d1 cleanup schemes and colors 2025-09-27 12:10:17 +02:00
Hiltjo Posthuma
74edc27caa config: make refreshrate for mouse move/resize a config option
Bump the default from 60 to 120.
2025-08-12 19:17:20 +02:00
6 changed files with 242 additions and 11 deletions

View File

@@ -12,10 +12,17 @@ static const char col_gray2[] = "#444444";
static const char col_gray3[] = "#bbbbbb"; static const char col_gray3[] = "#bbbbbb";
static const char col_gray4[] = "#eeeeee"; static const char col_gray4[] = "#eeeeee";
static const char col_cyan[] = "#005577"; static const char col_cyan[] = "#005577";
static const char col_black[] = "#000000";
static const char col_red[] = "#ff0000";
static const char col_yellow[] = "#ffff00";
static const char col_white[] = "#ffffff";
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 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan }, [SchemeSel] = { col_gray4, col_cyan, col_cyan },
[SchemeWarn] = { col_black, col_yellow, col_red },
[SchemeUrgent]= { col_white, col_red, col_red },
}; };
/* tagging */ /* tagging */
@@ -36,6 +43,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 */

126
config.h Normal file
View File

@@ -0,0 +1,126 @@
/* See LICENSE file for copyright and license details. */
#include "push.c"
/* appearance */
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 char *fonts[] = { "monospace:size=8" };
static const char dmenufont[] = "monospace:size=8";
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 col_red[] = "#dc322f";
static const char col_orange[] = "#cb4b16";
static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
[SchemeSel] = { col_gray4, col_cyan, col_cyan },
[SchemeUrgent] = { col_orange, col_gray1, col_gray2 },
[SchemeWarn] = { col_gray4, col_red, col_gray2 },
};
/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask isfloating monitor */
{ "Gimp", NULL, NULL, 0, 1, -1 },
// { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
};
/* layout(s) */
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 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 refreshrate = 120; /* refresh rate (per second) for client move/resize */
static const Layout layouts[] = {
/* symbol arrange function */
{ "[]=", tile }, /* first entry is default */
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
};
/* key definitions */
#define MODKEY Mod3Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* 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 };
static const char *termcmd[] = { "st", NULL };
static const Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } },
{ 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_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ 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_comma, focusmon, {.i = -1 } },
{ MODKEY, XK_period, focusmon, {.i = +1 } },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
{ MODKEY|ShiftMask, XK_j, pushdown, {0} },
{ MODKEY|ShiftMask, XK_k, pushup, {0} },
};
/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
{ ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
{ ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
};

29
drw.c
View File

@@ -178,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)
{ {
@@ -187,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++)
@@ -195,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)
{ {

2
drw.h
View File

@@ -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);

24
dwm.c
View File

@@ -58,7 +58,7 @@
/* enums */ /* enums */
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */ enum { SchemeNorm, SchemeSel, SchemeWarn, SchemeUrgent }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck, enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType, NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
@@ -486,7 +486,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);
@@ -701,6 +701,10 @@ drawbar(Monitor *m)
int boxs = drw->fonts->h / 9; int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2; int boxw = drw->fonts->h / 6 + 2;
unsigned int i, occ = 0, urg = 0; unsigned int i, occ = 0, urg = 0;
char *ts = stext;
char *tp = stext;
int tx = 0;
char ctmp;
Client *c; Client *c;
if (!m->showbar) if (!m->showbar)
@@ -710,7 +714,17 @@ drawbar(Monitor *m)
if (m == selmon) { /* status is only drawn on selected monitor */ if (m == selmon) { /* status is only drawn on selected monitor */
drw_setscheme(drw, scheme[SchemeNorm]); drw_setscheme(drw, scheme[SchemeNorm]);
tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */
drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); while (1) {
if ((unsigned int)*ts > LENGTH(colors)) { ts++; continue ; }
ctmp = *ts;
*ts = '\0';
drw_text(drw, m->ww - tw + tx, 0, tw - tx, bh, 0, tp, 0);
tx += TEXTW(tp) -lrpad;
if (ctmp == '\0') { break; }
drw_setscheme(drw, scheme[(unsigned int)(ctmp-1)]);
*ts = ctmp;
tp = ++ts;
}
} }
for (c = m->clients; c; c = c->next) { for (c = m->clients; c; c = c->next) {
@@ -1171,7 +1185,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;
@@ -1325,7 +1339,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;

58
push.c Normal file
View File

@@ -0,0 +1,58 @@
static Client *
prevtiled(Client *c) {
Client *p, *r;
for(p = selmon->clients, r = NULL; p && p != c; p = p->next)
if(!p->isfloating && ISVISIBLE(p))
r = p;
return r;
}
static void
pushup(const Arg *arg) {
Client *sel = selmon->sel;
Client *c;
if(!sel || sel->isfloating)
return;
if((c = prevtiled(sel))) {
/* attach before c */
detach(sel);
sel->next = c;
if(selmon->clients == c)
selmon->clients = sel;
else {
for(c = selmon->clients; c->next != sel->next; c = c->next);
c->next = sel;
}
} else {
/* move to the end */
for(c = sel; c->next; c = c->next);
detach(sel);
sel->next = NULL;
c->next = sel;
}
focus(sel);
arrange(selmon);
}
static void
pushdown(const Arg *arg) {
Client *sel = selmon->sel;
Client *c;
if(!sel || sel->isfloating)
return;
if((c = nexttiled(sel->next))) {
/* attach after c */
detach(sel);
sel->next = c->next;
c->next = sel;
} else {
/* move to the front */
detach(sel);
attach(sel);
}
focus(sel);
arrange(selmon);
}